From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mx.groups.io with SMTP id smtpd.web10.11487.1675333300851208931 for ; Thu, 02 Feb 2023 02:21:45 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cMG62ZIB; spf=pass (domain: gmail.com, ip: 209.85.218.49, mailfrom: savvamtr@gmail.com) Received: by mail-ej1-f49.google.com with SMTP id m2so4525218ejb.8 for ; Thu, 02 Feb 2023 02:21:44 -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=IL7XtK5gteqyAi+EsAo0ATnuSHXKgtjeRLEAPb0mFO8=; b=cMG62ZIBYSSGKjmF1CDJetpju8QpChoOFi9Yc+NqhMin716k2t6uC74+nErF7kG5GE olS6unSvr+iPj3+8nOVm7kiPAmV6GyMgwJQ7keGTLEhl7W9OuIOAwE1U7uyyMRb1Oagt QlsaT9DaTrpwhbpApe/T3DV5QshbSyH1XNS6I3heuhY0rMjbW3UHnRNH2Pi/wOBbJXX+ Xgb/k50tDlix/cL4yduU7TZ+qBJxxS5O2QZ5zPwp+5jh7uGachmL2vd2luVgqxtBoK9T RIk19HwdYidmv463bOmVBbKGnmvCuWlEgJOb5mfUmUppoCp6nju142oydXSGXCbAm4YP lIVw== 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=IL7XtK5gteqyAi+EsAo0ATnuSHXKgtjeRLEAPb0mFO8=; b=GPVU77l/vWz4tRbqlJTQdmCtPYzNpqY5TuRV6A/u3ZVammfIigCjz+AcnIjyQhSw9b jP9SGNsIXuJhRCb4y5YCOEpS0qttSSo7ZJYJLLK0tTEkYqTX3LdV1OdhvSbPqspYtIsn a8O5R8vSgD6cdU8G5Vn+fq7m+LCYD1KSuk6A2uDrD9rdJESPl/DLUnW6gCknqT9YdDh4 GUxt9aIN2hXUa0PTE66CWJ4n9FwIljXDclVboJA+ajM3X3waacONfO8m+OfV7NBGiv70 8+9sl8Y7dTUw7PDWz5EgX08DbzQs/3JRuKZbIwO/w3ej5Qj+B+kP/wINf0uk3Jnn6DFC DtMQ== X-Gm-Message-State: AO0yUKXA/RHLTyIxJjAODw8Qpz2yzJoq7xE2q1Nfldxop7P2ZKeIxcMc QhGloyDJ8pVhxdjKLNUFM19lmIQFDajeXg== X-Google-Smtp-Source: AK7set97UMS3YRKzfadnF58/1/bC6rt6KOzydsRL3hXD8iZ2+1tIPZIw+3dNKQvFNEcQW8oHrRvIIQ== X-Received: by 2002:a17:906:4fc7:b0:87b:1be:a8c2 with SMTP id i7-20020a1709064fc700b0087b01bea8c2mr6302649ejw.73.1675333304365; Thu, 02 Feb 2023 02:21:44 -0800 (PST) Return-Path: Received: from localhost.localdomain ([176.62.67.29]) by smtp.gmail.com with ESMTPSA id ci22-20020a170906c35600b0087bcda2b07bsm10013121ejb.202.2023.02.02.02.21.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Feb 2023 02:21:44 -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 v4 07/12] Ext4Pkg: Check that source file is directory in Ext4OpenInternal Date: Thu, 2 Feb 2023 16:21:28 +0600 Message-Id: <20230202102133.51606-8-savvamtr@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202102133.51606-1-savvamtr@gmail.com> References: <20230202102133.51606-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 Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov Reviewed-by: Pedro Falcato Reviewed-by: Marvin H=C3=A4user --- 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 8dfe324255f4..9dde4a5d1a2d 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.39.1