Fix a bug caused by sscanf trashing memory.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@280 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
bbahnsen 2006-05-25 18:18:27 +00:00
parent fbf910a5a0
commit 8d3adb745f
1 changed files with 27 additions and 15 deletions

View File

@ -690,21 +690,33 @@ Returns:
Ptrx++; Ptrx++;
} }
ArgCountParsed = sscanf ( {
Ptrx, int byte_index;
"%x, %x, %x, { %x, %x, %x, %x, %x, %x, %x, %x }", // This is an array of UINT32s. sscanf will trash memory
&Guid.Data1, // if you try to read into a UINT8 with a %x formatter.
&Guid.Data2, UINT32 Guid_Data4[8];
&Guid.Data3,
&Guid.Data4[0], ArgCountParsed = sscanf (
&Guid.Data4[1], Ptrx,
&Guid.Data4[2], "%x, %x, %x, { %x, %x, %x, %x, %x, %x, %x, %x }",
&Guid.Data4[3], &Guid.Data1,
&Guid.Data4[4], &Guid.Data2,
&Guid.Data4[5], &Guid.Data3,
&Guid.Data4[6], &Guid_Data4[0],
&Guid.Data4[7] &Guid_Data4[1],
); &Guid_Data4[2],
&Guid_Data4[3],
&Guid_Data4[4],
&Guid_Data4[5],
&Guid_Data4[6],
&Guid_Data4[7]
);
// Now we can copy the 32 bit ints into the GUID.
for (byte_index=0; byte_index<8; byte_index++) {
Guid.Data4[byte_index] = (UINT8) Guid_Data4[byte_index];
}
}
if (ArgCountParsed != 11) { if (ArgCountParsed != 11) {
printf ("We have found an illegal GUID\n"); printf ("We have found an illegal GUID\n");