[edk2-devel] [edk2-platforms][PATCH v4 11/12] Ext4Pkg: Filter out directory entry names containing \0 as invalid

Marvin Häuser mhaeuser at posteo.de
Thu Feb 2 10:30:07 UTC 2023


Reviewed-by: Marvin Häuser <mhaeuser at posteo.de>

> On 2. Feb 2023, at 11:21, Savva Mitrofanov <savvamtr at gmail.com> wrote:
> 
> The directory entry name conventions forbid having null-terminator
> symbols in its body and can lead to undefined behavior conditions
> and crashes
> 
> Cc: Marvin Häuser <mhaeuser at posteo.de>
> Cc: Pedro Falcato <pedro.falcato at gmail.com>
> Cc: Vitaly Cheptsov <vit9696 at protonmail.com>
> Fixes: 89b2bb0db263 ("Ext4Pkg: Fix and clarify handling regarding non-utf8 dir entries")
> Signed-off-by: Savva Mitrofanov <savvamtr at gmail.com>
> Reviewed-by: Pedro Falcato <pedro.falcato at gmail.com>
> ---
> Features/Ext4Pkg/Ext4Dxe/Directory.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dxe/Directory.c
> index dee8cfc66cb7..88f89a40534c 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c
> +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c
> @@ -28,9 +28,16 @@ Ext4GetUcs2DirentName (
> {
>   CHAR8       Utf8NameBuf[EXT4_NAME_MAX + 1];
>   UINT16      *Str;
> +  UINT8       Index;
>   EFI_STATUS  Status;
> 
> -  CopyMem (Utf8NameBuf, Entry->name, Entry->name_len);
> +  for (Index = 0; Index < Entry->name_len; ++Index) {
> +    if (Entry->name[Index] == '\0') {
> +      return EFI_INVALID_PARAMETER;
> +    }
> +
> +    Utf8NameBuf[Index] = Entry->name[Index];
> +  }
> 
>   Utf8NameBuf[Entry->name_len] = '\0';
> 
> -- 
> 2.39.1
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99460): https://edk2.groups.io/g/devel/message/99460
Mute This Topic: https://groups.io/mt/96697376/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