]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/GenCrc32: Fix a bug to hand empty file for decode
authorYonghong Zhu <yonghong.zhu@intel.com>
Wed, 19 Jul 2017 02:59:37 +0000 (10:59 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 1 Aug 2017 02:52:44 +0000 (10:52 +0800)
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>
BaseTools/Source/C/GenCrc32/GenCrc32.c

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