summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-25 18:18:27 +0000
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-05-25 18:18:27 +0000
commit8d3adb745fc1c57001aeba76532258282615e7cb (patch)
tree4d713bc6d1c813478f1e5620ee5a2df01774a3ed /Tools
parentfbf910a5a0f0c5635b4c5f04dad6d79ec55143f1 (diff)
downloadedk2-8d3adb745fc1c57001aeba76532258282615e7cb.zip
edk2-8d3adb745fc1c57001aeba76532258282615e7cb.tar.gz
edk2-8d3adb745fc1c57001aeba76532258282615e7cb.tar.bz2
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
Diffstat (limited to 'Tools')
-rw-r--r--Tools/Source/TianoTools/GenDepex/GenDepex.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/Tools/Source/TianoTools/GenDepex/GenDepex.c b/Tools/Source/TianoTools/GenDepex/GenDepex.c
index 2a65e08..608e27e 100644
--- a/Tools/Source/TianoTools/GenDepex/GenDepex.c
+++ b/Tools/Source/TianoTools/GenDepex/GenDepex.c
@@ -690,21 +690,33 @@ Returns:
Ptrx++;
}
- ArgCountParsed = sscanf (
- Ptrx,
- "%x, %x, %x, { %x, %x, %x, %x, %x, %x, %x, %x }",
- &Guid.Data1,
- &Guid.Data2,
- &Guid.Data3,
- &Guid.Data4[0],
- &Guid.Data4[1],
- &Guid.Data4[2],
- &Guid.Data4[3],
- &Guid.Data4[4],
- &Guid.Data4[5],
- &Guid.Data4[6],
- &Guid.Data4[7]
- );
+ {
+ int byte_index;
+ // This is an array of UINT32s. sscanf will trash memory
+ // if you try to read into a UINT8 with a %x formatter.
+ UINT32 Guid_Data4[8];
+
+ ArgCountParsed = sscanf (
+ Ptrx,
+ "%x, %x, %x, { %x, %x, %x, %x, %x, %x, %x, %x }",
+ &Guid.Data1,
+ &Guid.Data2,
+ &Guid.Data3,
+ &Guid_Data4[0],
+ &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) {
printf ("We have found an illegal GUID\n");