From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web11.45003.1670856424392905373 for ; Mon, 12 Dec 2022 06:47:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q4VSlNJ4; spf=pass (domain: gmail.com, ip: 209.85.167.53, mailfrom: savvamtr@gmail.com) Received: by mail-lf1-f53.google.com with SMTP id p36so18957577lfa.12 for ; Mon, 12 Dec 2022 06:47:08 -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=QUxZZ6m0L149Z/PV/ZpfHvu4nDU0c8r/RZsJkTwuTZA=; b=Q4VSlNJ4W2YwBZCDlWXtDX/Pu1GtDVPyLyxbdInp5F3Y/Vvd0AZwvsAFJHUhnrFiIg Vrwr2IkfUFrRsw1DoSuYNbbc7Tgz81nA6HNSu560q9h6g0jFLvx3IOzWpUPksFyYSvbv ZNYdus/4bo/BE4jE0M3IiPrCkkVP+rYO3w0hIo4cmBdY+un0TKMKSewikfOMuRYLRmCB QYpZluMBZyULqM5cQNum9Lyc22ohkzdjdEmkHZ1deE2vkt5zXPhdkf/V/ujinNvN0u4N Y5KDzLX6zSUj4Nj2WcmzGUHWk2FDYHK+1Q7Qx9ogEqA/B3beB9vsSpCBFfbXpJbIFGUg MRZw== 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=QUxZZ6m0L149Z/PV/ZpfHvu4nDU0c8r/RZsJkTwuTZA=; b=w+WpODsbQNE0Qzys2YeFcDUo/1HJAqq7OfvyKD2axk9zr651D/eCi/tBH3o+IE7CHE WTuEq+HnegANlymkCSRd4CWSdGxRl3cB/0bokXUdu25/haW842mSLuAQ2bw5UCeN3BqV gn8NgurO8rlb4BqeEWvZjOe3hj3p1I3QnYuEseWuC21gMD4K/bNU4BedQYqR3GrIejh9 AS5gzCDOMnNMhAugDVYFwl+hPjY9XtK9Z8paisiyc1Gz4rIb+5Y74HXe/iDY8BRY7lyL um08vYD4qUNQxTBu9cYsphUEUWDBkyGc7g61yn0FbZtM6artS0tKMQ51u96g0D6lmPK7 WW4g== X-Gm-Message-State: ANoB5plifv4eKcp/8rXoWLZPICVklMmI7BvDYoFwSgyNEw9YSNRENdYo J+RMn5KiKs/4oT21PNA4f9VR+qLhhk/7IPhV X-Google-Smtp-Source: AA0mqf7VmnljBT6/PQ/TVow+xZa4r9agco5TdcGLgzsJ1eLGrb5nOr7y7s+MNV4UNRy4WvRUg+S57w== X-Received: by 2002:a05:6512:790:b0:4b5:9b8f:cc82 with SMTP id x16-20020a056512079000b004b59b8fcc82mr3758239lfr.0.1670856428223; Mon, 12 Dec 2022 06:47:08 -0800 (PST) Return-Path: Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:07 -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 v2 09/11] Ext4Pkg: Check that source file is directory in Ext4OpenInternal Date: Mon, 12 Dec 2022 20:46:52 +0600 Message-Id: <20221212144654.2650-10-savvamtr@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-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: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 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 04198a53bfc0..20a0194a5793 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