]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/FvLib.c
BaseTools: CommonLib Fix Crash to write the last byte
[mirror_edk2.git] / BaseTools / Source / C / Common / FvLib.c
index 4758749dc363d9885613120f2f4fc4c2b31d4bcb..f97a7f21ce63875d612c4100a7043ee2e0adfab6 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
+These functions assist in parsing and manipulating a Firmware Volume.\r
 \r
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, 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
@@ -9,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-Module Name:\r
-\r
-  FvLib.c\r
-\r
-Abstract:\r
-\r
-  These functions assist in parsing and manipulating a Firmware Volume.\r
-\r
 **/\r
 \r
 //\r
@@ -201,7 +194,7 @@ Returns:
   //\r
   // Get next file, compensate for 8 byte alignment if necessary.\r
   //\r
-  *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetFfsFileLength(CurrentFile) + 0x07) & (-1 << 3)) + (UINT8 *) mFvHeader);\r
+  *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetFfsFileLength(CurrentFile) + 0x07) & (~(UINTN) 7)) + (UINT8 *) mFvHeader);\r
 \r
   //\r
   // Verify file is in this FV.\r
@@ -486,7 +479,7 @@ Returns:
     //\r
     // Find next section (including compensating for alignment issues.\r
     //\r
-    CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetSectionFileLength(CurrentSection.CommonHeader) + 0x03) & (-1 << 2));\r
+    CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetSectionFileLength(CurrentSection.CommonHeader) + 0x03) & (~(UINTN) 3));\r
   }\r
 \r
   return EFI_NOT_FOUND;\r
@@ -791,7 +784,7 @@ Returns:
     return 0;\r
   }\r
   if (FfsHeader->Attributes & FFS_ATTRIB_LARGE_FILE) {\r
-    return ((EFI_FFS_FILE_HEADER2 *)FfsHeader)->ExtendedSize;\r
+    return (UINT32) ((EFI_FFS_FILE_HEADER2 *)FfsHeader)->ExtendedSize;\r
   } else {\r
     return GetLength(FfsHeader->Size);\r
   }\r