BaseTools/GenCrc32: Fix a bug to hand empty file for decode

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=535
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yonghong Zhu 2017-07-19 10:59:37 +08:00
parent b5bd6387d2
commit 997b2c5437
1 changed files with 6 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Calculate Crc32 value and Verify Crc32 value for input data. Calculate Crc32 value and Verify Crc32 value for input data.
Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -80,7 +80,7 @@ Returns:
// //
// Copyright declaration // Copyright declaration
// //
fprintf (stdout, "Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.\n\n"); fprintf (stdout, "Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.\n\n");
// //
// Details Option // Details Option
@ -326,6 +326,10 @@ Returns:
// //
// Verify Crc32 Value // Verify Crc32 Value
// //
if (FileSize < sizeof (UINT32)) {
Error (NULL, 0, 3000, "Invalid", "Input file is invalid!");
goto Finish;
}
Status = CalculateCrc32 (FileBuffer + sizeof (UINT32), FileSize - sizeof (UINT32), &Crc32Value); Status = CalculateCrc32 (FileBuffer + sizeof (UINT32), FileSize - sizeof (UINT32), &Crc32Value);
if (Status != EFI_SUCCESS) { if (Status != EFI_SUCCESS) {
Error (NULL, 0, 3000, "Invalid", "Calculate CRC32 value failed!"); Error (NULL, 0, 3000, "Invalid", "Calculate CRC32 value failed!");