audk/IntelFsp2Pkg
Chasel Chiu 9e639c1cb6 IntelFsp2Pkg/SplitFspBin.py: Command crashed when FV almost full.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2310

When target FV 99% used and only few bytes space left,
SplitFspBin.py may crash with below error:

  File "SplitFspBin.py", line 457, in ParseFv
    ffshdr = EFI_FFS_FILE_HEADER.from_buffer (self.FvData, offset)
ValueError: Buffer size too small
  (40960 instead of at least 40968 bytes)

It was because the offset used by FFS_HEADER parser out of bounds.
It should stop parsing when offset equal or larger than
(buffer size - FFS_HEADER size).

This patch also fixed another crash issue when running script with
Python 3.x and no input parameter given:

  File "SplitFspBin.py", line 868, in main
    if args.which in ['rebase', 'split', 'genhdr', 'info']:
AttributeError: 'Namespace' object has no attribute 'which'

Test:
1. Ran script with both py2 and py3 with no input and no crash observed.
2. Compare the script result before and after the patch are identical.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
2019-10-28 10:28:56 +08:00
..
FspNotifyPhase IntelFsp2Pkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:03 -07:00
FspSecCore IntelFsp2Pkg/FspSecCore: Remove unneeded MdeModulePkg dependency 2019-09-05 02:10:02 +08:00
Include IntelFsp2Pkg: Fix various typos 2019-07-11 21:07:17 +08:00
Library IntelFsp2Pkg: Fix various typos 2019-07-11 21:07:17 +08:00
Tools IntelFsp2Pkg/SplitFspBin.py: Command crashed when FV almost full. 2019-10-28 10:28:56 +08:00
IntelFsp2Pkg.dec IntelFsp2Pkg: add TempRamExitPpi.h. 2019-06-20 12:11:22 +08:00
IntelFsp2Pkg.dsc IntelFsp2Pkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:03 -07:00
Readme.md IntelFsp2Pkg: Convert files to CRLF line ending 2017-04-06 15:42:56 +08:00

Readme.md