From nobody Fri May 3 08:32:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515389452459591.2181208027444; Sun, 7 Jan 2018 21:30:52 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9F69C222EDCCC; Sun, 7 Jan 2018 21:25:41 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 90A2E22280C3E for ; Sun, 7 Jan 2018 21:25:39 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2018 21:30:48 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga002.fm.intel.com with ESMTP; 07 Jan 2018 21:30:47 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,329,1511856000"; d="scan'208";a="8276697" From: Hao Wu To: edk2-devel@lists.01.org Date: Mon, 8 Jan 2018 13:30:40 +0800 Message-Id: <20180108053044.11788-2-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180108053044.11788-1-hao.a.wu@intel.com> References: <20180108053044.11788-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 1/5] BaseTools/C/Common: Fix code to be more readable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Ruiyu Ni , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The change doesn't impact the functionality. Cc: Ruiyu Ni Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Liming Gao Reviewed-by: Yonghong Zhu --- BaseTools/Source/C/Common/CommonLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Com= mon/CommonLib.c index 90cc578e61..0e9aaa3735 100644 --- a/BaseTools/Source/C/Common/CommonLib.c +++ b/BaseTools/Source/C/Common/CommonLib.c @@ -2032,8 +2032,8 @@ StrToIpv6Address ( return RETURN_UNSUPPORTED; } memcpy (&Address->Addr[0], &LocalAddress.Addr[0], CompressStart); - memset (&Address->Addr[CompressStart], 0, ARRAY_SIZE (Address->Addr) - = AddressIndex); if (AddressIndex > CompressStart) { + memset (&Address->Addr[CompressStart], 0, ARRAY_SIZE (Address->Addr) = - AddressIndex); memcpy ( &Address->Addr[CompressStart + ARRAY_SIZE (Address->Addr) - AddressI= ndex], &LocalAddress.Addr[CompressStart], --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 08:32:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515389454501760.1854497071172; Sun, 7 Jan 2018 21:30:54 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 13AEA2236BA83; Sun, 7 Jan 2018 21:25:42 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8EE38222A54D8 for ; Sun, 7 Jan 2018 21:25:40 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2018 21:30:49 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga002.fm.intel.com with ESMTP; 07 Jan 2018 21:30:49 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,329,1511856000"; d="scan'208";a="8276701" From: Hao Wu To: edk2-devel@lists.01.org Date: Mon, 8 Jan 2018 13:30:41 +0800 Message-Id: <20180108053044.11788-3-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180108053044.11788-1-hao.a.wu@intel.com> References: <20180108053044.11788-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 2/5] BaseTools/C/Common: Fix potential memory leak X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Liming Gao Reviewed-by: Yonghong Zhu --- BaseTools/Source/C/Common/PcdValueCommon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BaseTools/Source/C/Common/PcdValueCommon.c b/BaseTools/Source/= C/Common/PcdValueCommon.c index 42f76ddbbc..611085cd2d 100644 --- a/BaseTools/Source/C/Common/PcdValueCommon.c +++ b/BaseTools/Source/C/Common/PcdValueCommon.c @@ -106,6 +106,9 @@ Returns: case 5: PcdList[PcdIndex].Value =3D Token; break; + default: + free (Token); + break; } } =20 --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 08:32:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515389457212247.6178571419664; Sun, 7 Jan 2018 21:30:57 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7855D2236BA90; Sun, 7 Jan 2018 21:25:43 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 92952222A54D8 for ; Sun, 7 Jan 2018 21:25:41 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2018 21:30:50 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga002.fm.intel.com with ESMTP; 07 Jan 2018 21:30:50 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,329,1511856000"; d="scan'208";a="8276709" From: Hao Wu To: edk2-devel@lists.01.org Date: Mon, 8 Jan 2018 13:30:42 +0800 Message-Id: <20180108053044.11788-4-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180108053044.11788-1-hao.a.wu@intel.com> References: <20180108053044.11788-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 3/5] BaseTools/DevicePath: Fix potential memory leak X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Liming Gao Reviewed-by: Yonghong Zhu --- BaseTools/Source/C/DevicePath/DevicePath.c | 1 + BaseTools/Source/C/DevicePath/DevicePathFromText.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/= C/DevicePath/DevicePath.c index 76b8553b71..4f859a0e44 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -190,5 +190,6 @@ int main(int argc, CHAR8 *argv[]) } PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8= ); putchar('\n'); + free(Str16); return STATUS_SUCCESS; } diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools= /Source/C/DevicePath/DevicePathFromText.c index 3d2f5a811c..120f2a38a2 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c @@ -3277,6 +3277,17 @@ UefiDevicePathLibConvertTextToDeviceNode ( // FromText =3D DevPathFromTextFilePath; DeviceNode =3D FromText (DeviceNodeStr); + // + // According to above logic, if 'FromText' is NULL in the 'if' stateme= nt, + // then 'ParamStr' must be NULL as well. No memory allocation has been= made + // in this case. + // + // The below check is for addressing a false positive potential memory= leak + // issue raised from static analysis. + // + if (ParamStr !=3D NULL) { + free (ParamStr); + } } else { DeviceNode =3D FromText (ParamStr); free (ParamStr); --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 08:32:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515389460159787.1915947867093; Sun, 7 Jan 2018 21:31:00 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id ED8242236BA93; Sun, 7 Jan 2018 21:25:43 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 92099222EDCEC for ; Sun, 7 Jan 2018 21:25:42 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2018 21:30:51 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga002.fm.intel.com with ESMTP; 07 Jan 2018 21:30:51 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,329,1511856000"; d="scan'208";a="8276719" From: Hao Wu To: edk2-devel@lists.01.org Date: Mon, 8 Jan 2018 13:30:43 +0800 Message-Id: <20180108053044.11788-5-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180108053044.11788-1-hao.a.wu@intel.com> References: <20180108053044.11788-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 4/5] BaseTools/C/Common: Fix potential null pointer dereference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Liming Gao Reviewed-by: Yonghong Zhu --- BaseTools/Source/C/Common/PcdValueCommon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BaseTools/Source/C/Common/PcdValueCommon.c b/BaseTools/Source/= C/Common/PcdValueCommon.c index 611085cd2d..4b4f137ecf 100644 --- a/BaseTools/Source/C/Common/PcdValueCommon.c +++ b/BaseTools/Source/C/Common/PcdValueCommon.c @@ -72,6 +72,9 @@ Returns: CHAR8 *Token; =20 Token =3D malloc (TokenEnd - TokenStart + 1); + if (Token =3D=3D NULL) { + return; + } memcpy (Token, &FileBuffer[TokenStart], TokenEnd - TokenStart); Token[TokenEnd - TokenStart] =3D 0; switch (TokenIndex) { @@ -333,6 +336,10 @@ Returns: Value =3D End + 1; } Buffer =3D malloc(*Size); + if (Buffer =3D=3D NULL) { + *Size =3D 0; + return NULL; + } Value =3D &PcdList[Index].Value[1]; for (*Size =3D 0, Buffer[*Size] =3D (UINT8) strtoul(Value, &End, 16); = Value !=3D End; *Size =3D *Size + 1, Buffer[*Size] =3D (UINT8) strtoul(Valu= e, &End, 16)) { Value =3D End + 1; --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 08:32:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515389463335966.3986879933798; Sun, 7 Jan 2018 21:31:03 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 59B6F2236BA8D; Sun, 7 Jan 2018 21:25:46 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8E0052236BA92 for ; Sun, 7 Jan 2018 21:25:43 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2018 21:30:52 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga002.fm.intel.com with ESMTP; 07 Jan 2018 21:30:52 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,329,1511856000"; d="scan'208";a="8276726" From: Hao Wu To: edk2-devel@lists.01.org Date: Mon, 8 Jan 2018 13:30:44 +0800 Message-Id: <20180108053044.11788-6-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180108053044.11788-1-hao.a.wu@intel.com> References: <20180108053044.11788-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 5/5] BaseTools/DevicePath: Fix potential null pointer dereference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Liming Gao Reviewed-by: Yonghong Zhu --- BaseTools/Source/C/DevicePath/DevicePath.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/= C/DevicePath/DevicePath.c index 4f859a0e44..b67ff412eb 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -183,6 +183,11 @@ int main(int argc, CHAR8 *argv[]) } Ascii2UnicodeString(Str, Str16); DevicePath =3D UefiDevicePathLibConvertTextToDevicePath(Str16); + if (DevicePath =3D=3D NULL) { + fprintf(stderr, "Convert fail, Cannot convert text to a device path"); + free(Str16); + return STATUS_ERROR; + } while (!((DevicePath->Type =3D=3D END_DEVICE_PATH_TYPE) && (DevicePath->= SubType =3D=3D END_ENTIRE_DEVICE_PATH_SUBTYPE)) ) { PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] <<= 8); --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel