Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName

Missing check in some cases leads to failed StrCpyS call in
Ext4GetVolumeLabelInfo. Also correct condition that checks Inode pointer
for being NULL in Ext4AllocateInode

Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com>
This commit is contained in:
Savva Mitrofanov 2022-11-30 18:47:08 +06:00
parent 8f4875d7b5
commit b4077c6f4f
No known key found for this signature in database
GPG Key ID: 774924031750BF64
2 changed files with 9 additions and 3 deletions

View File

@ -727,6 +727,10 @@ Ext4GetVolumeName (
VolNameLength = StrLen (VolumeName);
} else {
VolumeName = AllocateZeroPool (sizeof (CHAR16));
if (VolumeName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VolNameLength = 0;
}
@ -793,7 +797,9 @@ Ext4GetFilesystemInfo (
Info->VolumeSize = MultU64x32 (TotalBlocks, Part->BlockSize);
Info->FreeSpace = MultU64x32 (FreeBlocks, Part->BlockSize);
StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);
Status = StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);
ASSERT_EFI_ERROR (Status);
FreePool (VolumeName);

View File

@ -230,7 +230,7 @@ Ext4AllocateInode (
Inode = AllocateZeroPool (InodeSize);
if (!Inode) {
if (Inode == NULL) {
return NULL;
}