]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenCrc32/GenCrc32.c
BaseTools: resolve initialization order errors in VfrFormPkg.h
[mirror_edk2.git] / BaseTools / Source / C / GenCrc32 / GenCrc32.c
index ad8cf5776064df5753662421363fed84ca5f2a34..515358794bc078fe563147052e8acbec7c432a03 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Calculate Crc32 value and Verify Crc32 value for input data.\r
 \r
-Copyright (c) 2007 - 2014, 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
@@ -248,7 +248,7 @@ Returns:
   VerboseMsg ("%s tool start.", UTILITY_NAME);\r
   \r
   //\r
-  // Check Input paramters\r
+  // Check Input parameters\r
   //\r
   if (FileAction == CRC32_NULL) {\r
     Error (NULL, 0, 1001, "Missing option", "either the encode or the decode option must be specified!");\r
@@ -289,6 +289,7 @@ Returns:
   FileBuffer = (UINT8 *) malloc (FileSize);\r
   if (FileBuffer == NULL) {\r
     Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated!");\r
+    fclose (InFile);\r
     goto Finish;\r
   }\r
   \r
@@ -325,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