From nobody Mon Feb 9 00:19:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109139+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109139+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695887210; cv=none; d=zohomail.com; s=zohoarc; b=J1qp9vpDoAo6MYcQfqZ0RvjD+feX4YiOCvH3V8WO+Lvu+GBW1Xc7i9lTH5fugC7xod+fGh/VG6dIYiYMYxUNEtGbEz7eJxZ/AtsItaDAm8SoSre0OK9XwXSFPJrg1dWB1OtT4WxX6ehijOSBNXg1nZclI9OcTrd8kg/7VR8Y9p8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695887210; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=/nN3Ozqgv3UFHsd3UXPF+Xxq0LftbLCi7cs+jtAPSbg=; b=IvmwXyVXIlpGYW/K+l3Z7TiyZpMPFEuGLxe3MoZnuhw/VAaCXq6QE2NRnr7VWybYiGzJ6z7tVnnbh80Y6btcvaczZhpRW/xM5JqWo9VLdPvxISO+0cQgY+1FQFrbhuZ6y17INCuTk49FzuOIFzRP5bHcgRSY2gyXtYDS+1INesQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109139+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695887210478685.1892330951309; Thu, 28 Sep 2023 00:46:50 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=qDGOUAwSyEThVztz3LHs/41f5Gr6mOLntWUKMniXeMQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695887210; v=1; b=eQA9bQxPX2E06tzNIZnPLYQKZCJRN6Ssu+50U3+ry/e8Dh/8T5AySLZM5KYv1Q8Pe/HXXJ1M gbWlqZHQlSxdnCzj+cRl30OsbBYWdKjYml6o+Hc4qgsyCxzBUZmzGNUG6YdxC7CkdGMhlRKbKtD eS9zSNemJk/CV8ifEdZnWP4I= X-Received: by 127.0.0.2 with SMTP id YHX1YY1788612xGSbQVOynHO; Thu, 28 Sep 2023 00:46:50 -0700 X-Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by mx.groups.io with SMTP id smtpd.web11.8857.1695887209655896630 for ; Thu, 28 Sep 2023 00:46:49 -0700 X-Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-3513c435465so21775325ab.0 for ; Thu, 28 Sep 2023 00:46:49 -0700 (PDT) X-Gm-Message-State: EcvbhkPkXL2ayGf89GEkSzmIx1787277AA= X-Google-Smtp-Source: AGHT+IGhvavgeeKorf2IuAY4MyQOf/BtA/DjOkHtJqmOewmXDLKhHSXhpv5mU2+nmO/Jc5tO/vxAMQ== X-Received: by 2002:a05:6e02:1c46:b0:351:33b0:176e with SMTP id d6-20020a056e021c4600b0035133b0176emr425657ilg.12.1695887208775; Thu, 28 Sep 2023 00:46:48 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1cbc:99f:6dc7:3128:6646:ac3f]) by smtp.gmail.com with ESMTPSA id y13-20020a02ce8d000000b0043a1f6dc8d4sm4342751jaq.4.2023.09.28.00.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 00:46:48 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 1/2] FatPkg/EnhancedFatDxe: Fix SIGN_EXTENSION Coverity issues Date: Thu, 28 Sep 2023 13:16:38 +0530 Message-Id: <20230928074639.561998-2-rsingh@ventanamicro.com> In-Reply-To: <20230928074639.561998-1-rsingh@ventanamicro.com> References: <20230928074639.561998-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695887212323100005 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The functions FatGetDirEntInfo and FatOpenDirEnt contains the code statements Cluster =3D (Entry->FileClusterHigh << 16) | Entry->FileCl= uster; and OFile->FileCluster =3D ((DirEnt->Entry.FileClusterHigh) << 16) | (Dir= Ent->Entry.FileCluster); respectively. As per Coverity report, in both these statements, there is an "Operand1" with type "UINT16" (16 bits, unsigned) which is promoted in "(Operand1 << 16) | Operand2" to type "int" (32 bits, signed), then sign- extended to type "unsigned long long" (64 bits, unsigned). If the result of "(Operand1 << 16) | Operand2" is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. So to avoid sign-extension, typecast the Operand1 and then the inter- -mediate result after << 16 operation with UINTN. Note - UINTN is the data type of the variable on the LHS of the assignment. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4249 Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- FatPkg/EnhancedFatDxe/DirectoryManage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FatPkg/EnhancedFatDxe/DirectoryManage.c b/FatPkg/EnhancedFatDx= e/DirectoryManage.c index 723fc35f38db..a21b7973cd21 100644 --- a/FatPkg/EnhancedFatDxe/DirectoryManage.c +++ b/FatPkg/EnhancedFatDxe/DirectoryManage.c @@ -474,7 +474,7 @@ FatGetDirEntInfo ( Info =3D Buffer; Info->Size =3D ResultSize; if ((Entry->Attributes & FAT_ATTRIBUTE_DIRECTORY) !=3D 0) { - Cluster =3D (Entry->FileClusterHigh << 16) | Entry->FileC= luster; + Cluster =3D (UINTN)((UINTN)(Entry->FileClusterHigh) << 16= ) | Entry->FileCluster; Info->PhysicalSize =3D FatPhysicalDirSize (Volume, Cluster); Info->FileSize =3D Info->PhysicalSize; } else { @@ -1167,7 +1167,7 @@ FatOpenDirEnt ( // Volume =3D Parent->Volume; OFile->FullPathLen =3D Parent->FullPathLen + 1 + StrLen (DirEnt->Fil= eString); - OFile->FileCluster =3D ((DirEnt->Entry.FileClusterHigh) << 16) | (Di= rEnt->Entry.FileCluster); + OFile->FileCluster =3D (UINTN)((UINTN)(DirEnt->Entry.FileClusterHigh= ) << 16) | (DirEnt->Entry.FileCluster); InsertTailList (&Parent->ChildHead, &OFile->ChildLink); } else { // --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109139): https://edk2.groups.io/g/devel/message/109139 Mute This Topic: https://groups.io/mt/101633788/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-