]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Fix wrong type of arguments to formatting functions
authorMichael Kubacki <michael.kubacki@microsoft.com>
Tue, 8 Nov 2022 17:17:59 +0000 (12:17 -0500)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 9 Nov 2022 14:53:10 +0000 (14:53 +0000)
Fixes issues found with the cpp/wrong-type-format-argument CodeQL
rule in BaseTools.

Reference:
https://cwe.mitre.org/data/definitions/686.html

The following CodeQL errors are resolved:

1. Check failure on line 1115 in
   BaseTools/Source/C/EfiRom/EfiRom.c

   - This argument should be of type 'int' but is of type 'char *'.
   - This argument should be of type 'int' but is of type 'signed
     char *'.

2. Check failure on line 359 in
   BaseTools/Source/C/GenFw/Elf32Convert.c

   - This argument should be of type 'CHAR8 *' but is of type
     'unsigned int'.

3. Check failure on line 1841 in
   BaseTools/Source/C/GenFw/Elf64Convert.c

   - This argument should be of type 'unsigned int' but is of type
     'unsigned long long'.

4. Check failure on line 1871 in
   BaseTools/Source/C/GenFw/Elf64Convert.c

   - This argument should be of type 'unsigned int' but is of type
     'unsigned long long'.

5. Check failure on line 2400 in
   BaseTools/Source/C/GenFv/GenFvInternalLib.c

   - This argument should be of type 'unsigned long long' but is of
     type 'unsigned int'.

6. Check failure on line 1099 in
   BaseTools/Source/C/GenFw/Elf64Convert.c

   - This argument should be of type 'CHAR8 *' but is of type
     'unsigned int'.

7. Check failure on line 1098 in
   BaseTools/Source/C/GenSec/GenSec.c

   - This argument should be of type 'CHAR8 *' but is of type
     'char **'.

8. Check failure on line 911 in
   BaseTools/Source/C/GenSec/GenSec.c

  - This argument should be of type 'CHAR8 *' but is of type
    'char **'.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
BaseTools/Source/C/EfiRom/EfiRom.c
BaseTools/Source/C/GenFv/GenFvInternalLib.c
BaseTools/Source/C/GenFw/Elf32Convert.c
BaseTools/Source/C/GenFw/Elf64Convert.c
BaseTools/Source/C/GenSec/GenSec.c

index 2506f559d574ce5316d00e08cb4e7dbd2a636297..fa7bf0e62e6dd3438b6141d6bd70b7c123188698 100644 (file)
@@ -1112,7 +1112,7 @@ Returns:
           goto Done;\r
         }\r
         if (DebugLevel > 9)  {\r
-          Error (NULL, 0, 2000, "Invalid option value", "Debug Level range is 0-9, current input level is %d", Argv[1]);\r
+          Error (NULL, 0, 2000, "Invalid option value", "Debug Level range is 0-9, current input level is %llu", DebugLevel);\r
           ReturnStatus = 1;\r
           goto Done;\r
         }\r
index b5b94250033474ac12bda63ee724dc644191304e..6bd59515b1aa28f638ff574a15735d8595af4c0f 100644 (file)
@@ -2397,7 +2397,7 @@ Returns:
   VerboseMsg("SecCore entry point Address = 0x%llX", (unsigned long long) SecCoreEntryAddress);\r
   VerboseMsg("BaseAddress = 0x%llX", (unsigned long long) FvInfo->BaseAddress);\r
   bSecCore = (UINT32)(SecCoreEntryAddress - FvInfo->BaseAddress);\r
-  VerboseMsg("offset = 0x%llX", bSecCore);\r
+  VerboseMsg("offset = 0x%X", bSecCore);\r
 \r
   if(bSecCore > 0x0fffff) {\r
     Error(NULL, 0, 3000, "Invalid", "SEC Entry point must be within 1MB of start of the FV");\r
index d917a444c82d94e67d2a6bd76470fe29b4d0091b..87d7f133f1326ef9f2c6ae5de02142fee1b47c92 100644 (file)
@@ -356,7 +356,7 @@ ScanSections32 (
     mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);\r
   break;\r
   default:\r
-    VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)mEhdr->e_machine);\r
+    VerboseMsg ("%u unknown e_machine type. Assume IA-32", (UINTN)mEhdr->e_machine);\r
     mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);\r
   break;\r
   }\r
index c6092269e2d192dc11f131f0ab1aa0f9a962b5c4..8b50774beb1eebda24d00cea9014d9ec6749cb36 100644 (file)
@@ -1096,7 +1096,7 @@ ScanSections64 (
     break;\r
 \r
   default:\r
-    VerboseMsg ("%s unknown e_machine type. Assume X64", (UINTN)mEhdr->e_machine);\r
+    VerboseMsg ("%u unknown e_machine type. Assume X64", (UINTN)mEhdr->e_machine);\r
     NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_X64;\r
     NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
   }\r
@@ -1837,7 +1837,7 @@ WriteRelocations64 (
             case R_X86_64_REX_GOTPCRELX:\r
               break;\r
             case R_X86_64_64:\r
-              VerboseMsg ("EFI_IMAGE_REL_BASED_DIR64 Offset: 0x%08X",\r
+              VerboseMsg ("EFI_IMAGE_REL_BASED_DIR64 Offset: 0x%08llX",\r
                 mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr));\r
               CoffAddFixup(\r
                 (UINT32) ((UINT64) mCoffSectionsOffset[RelShdr->sh_info]\r
@@ -1867,7 +1867,7 @@ WriteRelocations64 (
             //\r
             // case R_X86_64_32S:\r
             case R_X86_64_32:\r
-              VerboseMsg ("EFI_IMAGE_REL_BASED_HIGHLOW Offset: 0x%08X",\r
+              VerboseMsg ("EFI_IMAGE_REL_BASED_HIGHLOW Offset: 0x%08llX",\r
                 mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr));\r
               CoffAddFixup(\r
                 (UINT32) ((UINT64) mCoffSectionsOffset[RelShdr->sh_info]\r
index a4c2d19aa6f46fa44b917b1d7590871e3d8d6e1e..cf24d821aa966ac1612b9a16619fca68ec7f239f 100644 (file)
@@ -908,7 +908,7 @@ Returns:
     if (FileBuffer != NULL) {\r
       free (FileBuffer);\r
     }\r
-    Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", InputFileName);\r
+    Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", *InputFileName);\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
@@ -1095,7 +1095,7 @@ Returns:
     if (FileBuffer != NULL) {\r
       free (FileBuffer);\r
     }\r
-    Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", InputFileName);\r
+    Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", *InputFileName);\r
     return EFI_NOT_FOUND;\r
   }\r
 \r