From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mx.groups.io with SMTP id smtpd.web09.11631.1629557300023258598 for ; Sat, 21 Aug 2021 07:48:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lGmwbrGv; spf=pass (domain: gmail.com, ip: 209.85.221.46, mailfrom: pedro.falcato@gmail.com) Received: by mail-wr1-f46.google.com with SMTP id r7so18669112wrs.0 for ; Sat, 21 Aug 2021 07:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o1YElpailWiSNYZlCLfluCFLKlIByPiGZmm69IoP72Q=; b=lGmwbrGvLeLLSBi+4rt9+y7xLwlPTzMgdbgFX15l1nkCegJ9PQlSvSNAqPoxlP1SOa CTWziKYrrSGaVSXfMPbBnePpSvMX4B1J5+Qms0jcpwohhJERIM7g47mWbPKeEsLHJ89a Xhx92Ni0CBqfwwo76jdv6sIvDu3YTTuuGdJBQQ5TVUFTHOBwy957xjA9aQcYOFWLDhaj eX88EM3ds4flBcYDJArwoyKRNNjh6aYKfxPOrHBoMRacISFsZyxbscUNbyqisSFLapw3 1Gza5jHYX9pA8aECP0cUR603j6mTIDhhzXB3Z/7t3Rbl3UANCxY4QEXLruONDYkirWFR +4ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o1YElpailWiSNYZlCLfluCFLKlIByPiGZmm69IoP72Q=; b=aKfa/lY+b6cYMIM8e15ayA9ohMsovmwnmyOzKXq1Pbg/EQZMfWB6bGuOVjSgCAETh5 HfTFmVHxOCAxwZwcOwVLjNSICChac8hVeJJGE5jQ0q89mf8zcuEuDhfJYV/+LUJ9n1Ci WJjbcUrEvsrpwO6PXaQLN1JIG3QNwajl3ppDihmYqCiEveHOEZUwlQOrkTQ0ccUjhobi OVgYfJlBXNErOJNxoHkGeEobKx5X0UOx2J7O4nBafKj8vddAWN+fMStmk5hfGD8sWWGT DL3nlLXAlaAee8Hi10N4ytJ0GLraq2tFB5Zo3/ixYmOVBxiNm3YgljaQZSn3ZK42CERQ ZHIA== X-Gm-Message-State: AOAM533zzLaqbZBUuPUujMJtS7Y89U/0i1uhymbliGGQLyBoVpb3w7l5 lHimqFSt1yG8NkTgWoyh81f5gchSou2Ev1qO X-Google-Smtp-Source: ABdhPJzlbVmpHwhto2PyltRf9vA2HEclXNpIbdWQQYQvPpLhoiDMPYKs3YZDh5a+3NJTePIp4Zfn8A== X-Received: by 2002:adf:d083:: with SMTP id y3mr4321585wrh.56.1629557298305; Sat, 21 Aug 2021 07:48:18 -0700 (PDT) Return-Path: Received: from PC-PEDRO.lan (bl8-253-151.dsl.telepac.pt. [85.241.253.151]) by smtp.gmail.com with ESMTPSA id j17sm9118036wrt.69.2021.08.21.07.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 07:48:18 -0700 (PDT) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Pedro Falcato , Leif Lindholm , Michael D Kinney , Bret Barkelew Subject: [edk2-platforms PATCH v2 1/5] Ext4Pkg: Fix incorrect usage of Ext4InitExtentsMap. Date: Sat, 21 Aug 2021 15:47:06 +0100 Message-Id: <20210821144711.39546-2-pedro.falcato@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210821144711.39546-1-pedro.falcato@gmail.com> References: <20210821144711.39546-1-pedro.falcato@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Fixes bug triggered by ShellPkg code, in usage of EFI_FILE_PROTOCOL's Open(). Cc: Leif Lindholm Cc: Michael D Kinney Cc: Bret Barkelew Signed-off-by: Pedro Falcato --- Features/Ext4Pkg/Ext4Dxe/File.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/Fil= e.c index 0f5fa6f73fb6..a3eff2b48a07 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -207,6 +207,11 @@ Ext4Open ( =0D FileName +=3D Length;=0D =0D + if (StrCmp(PathSegment, L".") =3D=3D 0) {=0D + // Opens of "." are a no-op=0D + continue;=0D + }=0D +=0D DEBUG ((DEBUG_FS, "[ext4] Opening %s\n", PathSegment));=0D =0D if (!Ext4FileIsDir (Current)) {=0D @@ -512,12 +517,20 @@ Ext4GetFileInfo ( IN EXT4_FILE *File, OUT EFI_FILE_INFO *Info, IN OUT UINTN *BufferSize=0D )=0D {=0D - UINTN FileNameLen;=0D - UINTN FileNameSize;=0D - UINTN NeededLength;=0D + UINTN FileNameLen;=0D + UINTN FileNameSize;=0D + UINTN NeededLength;=0D + CONST CHAR16 *FileName;=0D =0D - FileNameLen =3D StrLen (File->FileName);=0D - FileNameSize =3D StrSize (File->FileName);=0D + if (File->InodeNum =3D=3D 2) {=0D + // Root inode gets a filename of "", regardless of how it was opened.= =0D + FileName =3D L"";=0D + } else {=0D + FileName =3D File->FileName;=0D + }=0D +=0D + FileNameLen =3D StrLen (FileName);=0D + FileNameSize =3D StrSize (FileName);=0D =0D NeededLength =3D SIZE_OF_EFI_FILE_INFO + FileNameSize;=0D =0D @@ -540,7 +553,7 @@ Ext4GetFileInfo ( =0D *BufferSize =3D NeededLength;=0D =0D - return StrCpyS (Info->FileName, FileNameLen + 1, File->FileName);=0D + return StrCpyS (Info->FileName, FileNameLen + 1, FileName);=0D }=0D =0D /**=0D @@ -687,6 +700,7 @@ Ext4DuplicateFile ( {=0D EXT4_PARTITION *Partition;=0D EXT4_FILE *File;=0D + EFI_STATUS Status;=0D =0D Partition =3D Original->Partition;=0D File =3D AllocateZeroPool (sizeof (EXT4_FILE));=0D @@ -717,7 +731,8 @@ Ext4DuplicateFile ( File->InodeNum =3D Original->InodeNum;=0D File->OpenMode =3D 0; // Will be filled by other code=0D =0D - if (!Ext4InitExtentsMap (File)) {=0D + Status =3D Ext4InitExtentsMap (File);=0D + if (EFI_ERROR (Status)) {=0D FreePool (File->FileName);=0D FreePool (File->Inode);=0D FreePool (File);=0D --=20 2.33.0