[edk2-devel] [edk2-platforms][PATCH v2 10/11] Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName
Savva Mitrofanov
savvamtr at gmail.com
Mon Dec 12 14:46:53 UTC 2022
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 <mhaeuser at posteo.de>
Cc: Pedro Falcato <pedro.falcato at gmail.com>
Cc: Vitaly Cheptsov <vit9696 at protonmail.com>
Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794
Signed-off-by: Savva Mitrofanov <savvamtr at gmail.com>
---
Features/Ext4Pkg/Ext4Dxe/File.c | 10 ++++++++--
Features/Ext4Pkg/Ext4Dxe/Inode.c | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/File.c
index 20a0194a5793..085cb7236957 100644
--- a/Features/Ext4Pkg/Ext4Dxe/File.c
+++ b/Features/Ext4Pkg/Ext4Dxe/File.c
@@ -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;
}
@@ -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);
diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/Inode.c
index 5ccb4d2bfc42..2977238d687c 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Inode.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c
@@ -230,7 +230,7 @@ Ext4AllocateInode (
Inode = AllocateZeroPool (InodeSize);
- if (!Inode) {
+ if (Inode == NULL) {
return NULL;
}
--
2.38.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97270): https://edk2.groups.io/g/devel/message/97270
Mute This Topic: https://groups.io/mt/95622339/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list