From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by mx.groups.io with SMTP id smtpd.web11.36481.1675066804370503174 for ; Mon, 30 Jan 2023 00:20:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cQFrhIFd; spf=pass (domain: gmail.com, ip: 209.85.218.46, mailfrom: savvamtr@gmail.com) Received: by mail-ej1-f46.google.com with SMTP id ml19so5819711ejb.0 for ; Mon, 30 Jan 2023 00:20:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=upvE9iI6BN22HhPjUONTiI0aHSPwedR21Zj4ZgMi1n4=; b=cQFrhIFd2TGehNJiuA83xc0+KZxcJZzYoImZVZ9z5xek+XGMQBEEd0gKSVQvSxu29f W/TKVGakuYRNmc1Zor8HuPwMf6Vx7MUFxs9FI9P+if+PjZsmNaif8qoymmyENM/Lkq5f +A+7fvPGXvgJ/rSjl7ge0YKc6I3Zf2YwwhmLzFEAhHFPSdmc+dEQ4cGvs7Ivo06e0+gM IhqFqOMeHJ1fLEC3Lpd3BO9skl3LpBgQjwrrusadBf60GhVuMYLhDy4bAgQt5VzBs18d HOhjOel4+jFQT4QoAYQEma0aO4LAK/aCj+SQ614I6fRHAYTLhsPh1wfVEUPNprQG6Qgr AcWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=upvE9iI6BN22HhPjUONTiI0aHSPwedR21Zj4ZgMi1n4=; b=GcwapcXrz6gWgJ+srJJygM4414HRvFRFiAI7YfSuSpdbXd14C00ilpfp2Ar5w3NwBs dC+Ubwbqc1038qlgzoZsUhJbkGqPMW44N+BDzPOPkFb/dqCGQrxiB6GynOaUCB1zYoC+ vq6+R+3rrlSRGgaNJq/vbYbME/kwl8+0kHP3/VEYDXG9nJnhR2QT/+R85Ccq4sQEgpbD H5Ed8Gbpp1aDeqnf2dzZ1ciDrFXY6mVDh8rvPVy4UB7xP9P2AGOH+JVK0AKHf+Uz37cH Csvpe4dLOnb1pwOQneSnMxkid0p3QW2uPaTnQWi+wRLSAYUTSgFHzW2rFvyCOHcsb/Wp JVDw== X-Gm-Message-State: AO0yUKUNww9bEvXGIsX0jxKfGxh7KqJqUFfyi/QCj3Bwu6CQJLJHorbp 7Ht/izje/6n41ppjB6H+t98= X-Google-Smtp-Source: AK7set8BrOjt60Gzli5dnmSPzx3/Xw03qzxlo2o8Zoh161/5DBsNIUhEzDK3eDmPK7+QJXKPTqEzsA== X-Received: by 2002:a17:906:3388:b0:888:94d3:37f5 with SMTP id v8-20020a170906338800b0088894d337f5mr2952548eja.63.1675066802701; Mon, 30 Jan 2023 00:20:02 -0800 (PST) Return-Path: Received: from smtpclient.apple ([176.62.67.29]) by smtp.gmail.com with ESMTPSA id m21-20020a1709062b9500b0086621d9d9b0sm6464550ejg.81.2023.01.30.00.19.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2023 00:20:00 -0800 (PST) Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: [edk2-platforms][PATCH v3 11/11] Ext4Pkg: Filter out directory entry names containing \0 as invalid From: "Savva Mitrofanov" In-Reply-To: Date: Mon, 30 Jan 2023 14:19:57 +0600 Cc: devel@edk2.groups.io, Pedro Falcato , =?utf-8?B?0JLQuNGC0LDQu9C40Lkg0K7RgNGM0LXQstC40Ycg0KfQtdC/0YbQvtCy?= Message-Id: References: <20230127092945.94389-1-savvamtr@gmail.com> <20230127092945.94389-12-savvamtr@gmail.com> To: =?utf-8?Q?Marvin_H=C3=A4user?= X-Mailer: Apple Mail (2.3696.120.41.1.2) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable It is not so important from my point of view, however, I corrected this = in the referenced repository fork. > On 27 Jan 2023, at 16:04, Marvin H=C3=A4user = wrote: >=20 > On 27. Jan 2023, at 10:29, Savva Mitrofanov = wrote: >>=20 >> The directory entry name conventions forbid having null-terminator >> symbols in its body and can lead to undefined behavior conditions >> and crashes >>=20 >> Cc: Marvin H=C3=A4user >> Cc: Pedro Falcato >> Cc: Vitaly Cheptsov >> Fixes: 89b2bb0db263 ("Ext4Pkg: Fix and clarify handling regarding = non-utf8 dir entries") >> Signed-off-by: Savva Mitrofanov >> --- >> Features/Ext4Pkg/Ext4Dxe/Directory.c | 9 ++++++++- >> 1 file changed, 8 insertions(+), 1 deletion(-) >>=20 >> diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c = b/Features/Ext4Pkg/Ext4Dxe/Directory.c >> index 0753a20b5377..465749c9b51d 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; >> + UINTN Index; >=20 > I *really* do not like UINTN in code that does not deal with buffer = addresses and sizes. I'd change it to UINT8, but I'll leave it up to = Pedro. >=20 >> EFI_STATUS Status; >>=20 >> - CopyMem (Utf8NameBuf, Entry->name, Entry->name_len); >> + for (Index =3D 0; Index < Entry->name_len; ++Index) { >> + if (Entry->name[Index] =3D=3D '\0') { >> + return EFI_INVALID_PARAMETER; >> + } >> + >> + Utf8NameBuf[Index] =3D Entry->name[Index]; >> + } >>=20 >> Utf8NameBuf[Entry->name_len] =3D '\0'; >>=20 >> --=20 >> 2.39.0 >>=20 >=20