mirror_edk2/BaseTools/Source/C/VfrCompile
Michael Kubacki dbe820d5fa BaseTools/VfrCompile: Fix potential buffer overwrites
While more portable methods exist to handle these cases, this change
does not attempt to do more than fix the immediate problem and
follow the conventions already established in this code.

`snprintf()` is introduced as the minimum improvement apart from
making the buffers larger.

Fixes the following CodeQL alerts:

1. Failure on line 2339 in
   BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c

   - Type: Potentially overrunning write
   - Severity: Critical
   - Problem: This 'call to sprintf' operation requires 17 bytes but
     the destination is only 16 bytes.

2. Failure on line 2341 in
   BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c

   - Type: Potentially overrunning write
   - Severity: Critical
   - Problem: This 'call to sprintf' operation requires 17 bytes but
     the destination is only 16 bytes.

3. Failure on line 1309 in
   BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c

   - Type: Potentially overrunning write
   - Severity: Critical
   - Problem: This 'call to sprintf' operation requires 25 bytes but
     the destination is only 20 bytes.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
2023-04-03 15:29:08 +00:00
..
Pccts BaseTools/VfrCompile: Fix potential buffer overwrites 2023-04-03 15:29:08 +00:00
EfiVfr.h BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
GNUmakefile Using LLVM compiler set to build BaseTools in Linux 2020-07-21 04:12:32 +00:00
Makefile BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
VfrCompiler.cpp BaseTools/VfrCompile: Remove framework VFR support 2019-05-09 09:42:54 +08:00
VfrCompiler.h BaseTools/VfrCompile: Remove framework VFR support 2019-05-09 09:42:54 +08:00
VfrError.cpp BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
VfrError.h BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
VfrFormPkg.cpp BaseTools/VfrCompile: Remove framework VFR support 2019-05-09 09:42:54 +08:00
VfrFormPkg.h BaseTools/VfrCompile: Correct Bit Field Flags for numeric/one of 2021-12-09 03:31:26 +00:00
VfrSyntax.g BaseTools/VfrCompile: Correct Bit Field Flags for numeric/one of 2021-12-09 03:31:26 +00:00
VfrUtilityLib.cpp BaseTools/VrfCompile: Fix uninitialized field from unnamed field 2021-11-03 23:43:46 +00:00
VfrUtilityLib.h BaseTools/VfrCompile: Remove framework VFR support 2019-05-09 09:42:54 +08:00