Fix infinite loop due to 0-sized volume files

closes #191
This commit is contained in:
vit9696 2020-01-24 22:36:39 +03:00
parent 516949a6e6
commit bf3adbe4c6

View File

@ -1467,6 +1467,11 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
while (fileOffset < volumeBodySize) { while (fileOffset < volumeBodySize) {
UINT32 fileSize = getFileSize(volumeBody, fileOffset, ffsVersion); UINT32 fileSize = getFileSize(volumeBody, fileOffset, ffsVersion);
if (fileSize == 0) {
msg(usprintf("%s: file header parsing failed with invalid size", __FUNCTION__), index);
return U_INVALID_PARAMETER;
}
// Check that we are at the empty space // Check that we are at the empty space
UByteArray header = volumeBody.mid(fileOffset, (int)std::min(sizeof(EFI_FFS_FILE_HEADER), (size_t)volumeBodySize - fileOffset)); UByteArray header = volumeBody.mid(fileOffset, (int)std::min(sizeof(EFI_FFS_FILE_HEADER), (size_t)volumeBodySize - fileOffset));
if (header.count(emptyByte) == header.size()) { //Empty space if (header.count(emptyByte) == header.size()) { //Empty space