]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Original range calculation in GetNextFile() is incorrect.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 10 Jan 2007 07:58:08 +0000 (07:58 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 10 Jan 2007 07:58:08 +0000 (07:58 +0000)
This patch fixes this issue.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2207 6f19259b-4bc3-4df7-8a09-765794883524

Tools/CCode/Source/Common/FvLib.c

index e8d62791f31251fe831b3a62877eb8209ca99efd..f526a30e1a6f0f2eda5b90a59d681758eb12b335 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
 All rights reserved. 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
@@ -180,7 +180,7 @@ Returns:
       //\r
       // Verify file is in this FV.\r
       //\r
-      if ((UINTN) CurrentFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FFS_FILE_HEADER)) {\r
+      if ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength) {\r
         *NextFile = NULL;\r
         return EFI_SUCCESS;\r
       }\r
@@ -192,9 +192,9 @@ Returns:
   //\r
   // Verify current file is in range\r
   //\r
-  if (((UINTN) CurrentFile < (UINTN) mFvHeader + sizeof (EFI_FIRMWARE_VOLUME_HEADER)) ||\r
-      ((UINTN) CurrentFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
-      ) {\r
+  if (((UINTN) CurrentFile < (UINTN) mFvHeader + mFvHeader->HeaderLength) ||\r
+      ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength)\r
+     ) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
@@ -205,7 +205,9 @@ Returns:
   //\r
   // Verify file is in this FV.\r
   //\r
-  if ((UINTN) *NextFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FFS_FILE_HEADER)) {\r
+  if (((UINTN) *NextFile + sizeof (EFI_FFS_FILE_HEADER) >= (UINTN) mFvHeader + mFvLength) ||\r
+      ((UINTN) *NextFile + GetLength ((*NextFile)->Size) > (UINTN) mFvHeader + mFvLength)\r
+     ) {\r
     *NextFile = NULL;\r
     return EFI_SUCCESS;\r
   }\r