@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.\r
@retval EFI_SUCCESS Successfully read volume header to the allocated\r
buffer.\r
+ @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
+ the file system could not be understood.\r
\r
**/\r
EFI_STATUS\r
return Status;\r
}\r
\r
+ //\r
+ // Validate FV Header signature, if not as expected, continue.\r
+ //\r
+ if (TempFvh.Signature != EFI_FVH_SIGNATURE) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Check to see that the file system is indeed formatted in a way we can\r
+ // understand it...\r
+ //\r
+ if ((!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&\r
+ (!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
//\r
// Allocate a buffer for the caller\r
//\r
FfsHeader = (EFI_FFS_FILE_HEADER *) (FvDevice->CachedFv);\r
}\r
TopFvAddress = FvDevice->EndOfCachedFv;\r
- while ((UINT8 *) FfsHeader < TopFvAddress) {\r
+ while (((UINTN) FfsHeader >= (UINTN) FvDevice->CachedFv) && ((UINTN) FfsHeader <= (UINTN) ((UINTN) TopFvAddress - sizeof (EFI_FFS_FILE_HEADER)))) {\r
\r
if (FileCached) {\r
CoreFreePool (CacheFfsHeader);\r
//\r
Status = GetFwVolHeader (Fvb, &FwVolHeader);\r
if (EFI_ERROR (Status)) {\r
- return;\r
+ continue;\r
}\r
ASSERT (FwVolHeader != NULL);\r
\r
continue;\r
}\r
\r
-\r
- //\r
- // Check to see that the file system is indeed formatted in a way we can\r
- // understand it...\r
- //\r
- if ((!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&\r
- (!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {\r
- continue;\r
- }\r
-\r
//\r
// Check if there is an FV protocol already installed in that handle\r
//\r