From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mx.groups.io with SMTP id smtpd.web10.5487.1670602278804047469 for ; Fri, 09 Dec 2022 08:11:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BwKMPOfW; spf=pass (domain: gmail.com, ip: 209.85.167.44, mailfrom: savvamtr@gmail.com) Received: by mail-lf1-f44.google.com with SMTP id 1so7768466lfz.4 for ; Fri, 09 Dec 2022 08:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sIKfsfEzW6qJR3yxpbKRgD/DlsWGYURjxwtpP2lwR08=; b=BwKMPOfWcK9Qs0FkGcKKLlDQmHHSHaRvsAloLkMj38BTq4GNegxFm5qhPRSdoXPu97 0AXa8Kl2o0VTFN4F6LRsHTUfd7NrU3OV5qSjjVPy7tWOg35N4u7CMqgihH74sb+RjWpA TtbTWhdVXauwo1/ryxacL5eIgO01RMV0TUq2JXx6nsfOR6aL0tvaeGYdFJIGoAexeX4f 3yI45fkz3lw8hriml3UVYkJOPiJNF3ynWdtTDNs2MMVzB4m5O88HgaDegdE3fdTcWiKU 81ht8OloylMzTW8MdZqHDyZ1/nQ+2mz9WoIL+/vZQD+NtjUvhGFWW/cd8g94lyFq62xw cZPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sIKfsfEzW6qJR3yxpbKRgD/DlsWGYURjxwtpP2lwR08=; b=ILd5cAEI5/c8H7m5FoHkfz5kHIzSaUfFcrvvo8ZFLfuT0i6jvK48qKNptKLA1bHgzb ForLWjzh0mWMlDlzh0QnVXzk1RYqclFHQ6DyrrCUQY//T0av6geV6tU6y9BczOC8hUZS 9AK7+7w50LF9UU22KM7M/BKKXBMd+h+c/sumZO+rUcfoy8u5Dw1xqobnfAgmBoBuGLGW zTLt1NDonfselosZBi0fU2J3fbOHt4dAHQN22P5jMWMNJn/KIeFm/ZGJ9XTys+D6PTlD PDJqxcW4ywU3fUk4UI9dIlnO778DArGEW928noXcJ9QR46DwuKdsCvmVqryDEV7l7Qy+ rTGA== X-Gm-Message-State: ANoB5pn8/y+ua3M59n2rVKjNgiwtE541tjSaztRz0uByC6PxSeQd8D48 5Q5ZxP0HO6CCqFfxYRAh6apQ88PKzJYr2+SW X-Google-Smtp-Source: AA0mqf7wBdxNtfi1BxAC4zUL6URrJr1FqCXPh4ucnCr+zrdbWoluoZs9BjbDPLGSRbDOH1YbFhWUog== X-Received: by 2002:ac2:43d8:0:b0:4ab:7f8d:472 with SMTP id u24-20020ac243d8000000b004ab7f8d0472mr1547267lfl.65.1670602284986; Fri, 09 Dec 2022 08:11:24 -0800 (PST) Return-Path: Received: from localhost.localdomain ([109.194.121.139]) by smtp.gmail.com with ESMTPSA id v5-20020a05651203a500b00492c663bba2sm318430lfp.124.2022.12.09.08.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 08:11:24 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-platforms][PATCH v1 10/12] Ext4Pkg: Check that source file is directory in Ext4OpenInternal Date: Fri, 9 Dec 2022 22:11:02 +0600 Message-Id: <20221209161104.70220-11-savvamtr@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209161104.70220-1-savvamtr@gmail.com> References: <20221209161104.70220-1-savvamtr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This check already present in the while loop below, but absent for cases when input file is nameless, so to handle assertion in Ext4ReadFile we need to add it at the top of function Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/File.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/Fil= e.c index b4ed78847258..2d76e1818021 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -207,6 +207,11 @@ Ext4OpenInternal ( Level =3D 0;=0D =0D DEBUG ((DEBUG_FS, "[ext4] Ext4OpenInternal %s\n", FileName));=0D +=0D + if (!Ext4FileIsDir (Current)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D // If the path starts with a backslash, we treat the root directory as t= he base directory=0D if (FileName[0] =3D=3D L'\\') {=0D FileName++;=0D @@ -219,6 +224,10 @@ Ext4OpenInternal ( return EFI_ACCESS_DENIED;=0D }=0D =0D + if (!Ext4FileIsDir (Current)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D // Discard leading path separators=0D while (FileName[0] =3D=3D L'\\') {=0D FileName++;=0D @@ -242,10 +251,6 @@ Ext4OpenInternal ( =0D DEBUG ((DEBUG_FS, "[ext4] Opening %s\n", PathSegment));=0D =0D - if (!Ext4FileIsDir (Current)) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D if (!Ext4IsLastPathSegment (FileName)) {=0D if (!Ext4DirCanLookup (Current)) {=0D return EFI_ACCESS_DENIED;=0D --=20 2.38.1