From 997b2c543751cb4a3473270c1a7016ade311f01b Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Wed, 19 Jul 2017 10:59:37 +0800 Subject: [PATCH] BaseTools/GenCrc32: Fix a bug to hand empty file for decode Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=535 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- BaseTools/Source/C/GenCrc32/GenCrc32.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/C/GenCrc32/GenCrc32.c b/BaseTools/Source/C/GenCrc32/GenCrc32.c index e1e11c6413..515358794b 100644 --- a/BaseTools/Source/C/GenCrc32/GenCrc32.c +++ b/BaseTools/Source/C/GenCrc32/GenCrc32.c @@ -1,7 +1,7 @@ /** @file Calculate Crc32 value and Verify Crc32 value for input data. -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials 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 @@ -80,7 +80,7 @@ Returns: // // 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 @@ -326,6 +326,10 @@ Returns: // // 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); if (Status != EFI_SUCCESS) { Error (NULL, 0, 3000, "Invalid", "Calculate CRC32 value failed!");