Skip to content

Commit

Permalink
Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName
Browse files Browse the repository at this point in the history
Missing check in some cases leads to failed StrCpyS call in
Ext4GetVolumeLabelInfo. Also correct condition that checks Inode pointer
for being NULL in Ext4AllocateInode

Cc: Marvin Häuser <[email protected]>
Cc: Pedro Falcato <[email protected]>
Cc: Vitaly Cheptsov <[email protected]>
Fixes: cfbbae5 ("Ext4Pkg: Add handling of EFI_FILE_SYSTEM_VOLUME_LABEL GetInfo().")
Signed-off-by: Savva Mitrofanov <[email protected]>
Reviewed-by: Pedro Falcato <[email protected]>
Reviewed-by: Marvin Häuser <[email protected]>
  • Loading branch information
savvamitrofanov authored and heatd committed Feb 8, 2023
1 parent d0cd979 commit dc30a62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Features/Ext4Pkg/Ext4Dxe/File.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,11 @@ Ext4GetVolumeName (

VolNameLength = StrLen (VolumeName);
} else {
VolumeName = AllocateZeroPool (sizeof (CHAR16));
VolumeName = AllocateZeroPool (sizeof (CHAR16));
if (VolumeName == NULL) {
return EFI_OUT_OF_RESOURCES;
}

VolNameLength = 0;
}

Expand Down Expand Up @@ -786,7 +790,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);

Expand Down
2 changes: 1 addition & 1 deletion Features/Ext4Pkg/Ext4Dxe/Inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Ext4AllocateInode (

Inode = AllocateZeroPool (InodeSize);

if (!Inode) {
if (Inode == NULL) {
return NULL;
}

Expand Down

0 comments on commit dc30a62

Please sign in to comment.