]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Image/Image.c
Validate some fields in PE image to make sure not access violation for later code.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Image / Image.c
index abafa222e7e63d3010c6f9471bf38b46219249fc..e51a9fe1743b8391e2d7bbf5c0341f84ffec7e4a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Core image handling services to load and unload PeImage.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, 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
@@ -232,6 +232,14 @@ CoreReadImageFile (
   UINTN               EndPosition;\r
   IMAGE_FILE_HANDLE  *FHand;\r
 \r
+  if (UserHandle == NULL || ReadSize == NULL || Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (MAX_ADDRESS - Offset < *ReadSize) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   FHand = (IMAGE_FILE_HANDLE  *)UserHandle;\r
   ASSERT (FHand->Signature == IMAGE_FILE_HANDLE_SIGNATURE);\r
 \r