X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FTianoTools%2FGenDepex%2FGenDepex.c;h=3818649330555051e951ae5883c11833d6b76d13;hp=2a65e086fcafa923e9375c92a5b7d442219ba9d8;hb=a7aa21c958525fd57c113d49c89b93f4993fac43;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4 diff --git a/Tools/Source/TianoTools/GenDepex/GenDepex.c b/Tools/Source/TianoTools/GenDepex/GenDepex.c index 2a65e086fc..3818649330 100644 --- a/Tools/Source/TianoTools/GenDepex/GenDepex.c +++ b/Tools/Source/TianoTools/GenDepex/GenDepex.c @@ -209,7 +209,7 @@ EFI_STATUS GenerateDependencyExpression ( IN FILE *InFile, IN OUT FILE *OutFile, - IN UINT8 Padding OPTIONAL + IN INT8 Padding OPTIONAL ) /*++ @@ -374,6 +374,7 @@ Returns: return EFI_ABORTED; } + memset (Buffer, 0, FileSize + BUFFER_SIZE); fread (Buffer, FileSize, 1, InFile); Ptrx = Buffer; @@ -690,21 +691,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"); @@ -716,11 +729,11 @@ Returns: Ptrx++; } - Ptrx++; + Ptrx++; while (*Ptrx != '}') { Ptrx++; } - // + // // Absorb the closing } // Ptrx++; @@ -842,16 +855,6 @@ Returns: Output_Flag = FALSE; Pad_Flag = FALSE; - // - // Output the calling arguments - // - printf ("\n\n"); - for (Index = 0; Index < argc; Index++) { - printf ("%s ", argv[Index]); - } - - printf ("\n\n"); - if (argc < 5) { printf ("Not enough arguments\n"); PrintGenDepexUsageInfo ();