From nobody Tue Jan 14 22:26:46 2025 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 1513654164599320.13041974601344; Mon, 18 Dec 2017 19:29:24 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E25C02035BA32; Mon, 18 Dec 2017 19:24:35 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 0C76D2035BA25 for ; Mon, 18 Dec 2017 19:24:35 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2017 19:29:21 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga006.fm.intel.com with ESMTP; 18 Dec 2017 19:29:20 -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=192.55.52.43; helo=mga05.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.45,424,1508828400"; d="scan'208";a="188196691" From: Hao Wu To: edk2-devel@lists.01.org Date: Tue, 19 Dec 2017 11:28:56 +0800 Message-Id: <20171219032912.14404-2-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20171219032912.14404-1-hao.a.wu@intel.com> References: <20171219032912.14404-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 01/17] BaseTools/C/Common: Add checks for array access X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 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: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- BaseTools/Source/C/Common/Decompress.c | 8 ++++---- BaseTools/Source/C/Common/SimpleFileParsing.c | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/BaseTools/Source/C/Common/Decompress.c b/BaseTools/Source/C/Co= mmon/Decompress.c index b2049bd01c..8f1afb4e40 100644 --- a/BaseTools/Source/C/Common/Decompress.c +++ b/BaseTools/Source/C/Common/Decompress.c @@ -2,7 +2,7 @@ Decompressor. Algorithm Ported from OPSD code (Decomp.asm) for Efi and Tia= no=20 compress algorithm. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -394,7 +394,7 @@ Returns: =20 Index =3D 0; =20 - while (Index < Number) { + while (Index < Number && Index < NPT) { =20 CharC =3D (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3)); =20 @@ -413,14 +413,14 @@ Returns: if (Index =3D=3D Special) { CharC =3D (UINT16) GetBits (Sd, 2); CharC--; - while ((INT16) (CharC) >=3D 0) { + while ((INT16) (CharC) >=3D 0 && Index < NPT) { Sd->mPTLen[Index++] =3D 0; CharC--; } } } =20 - while (Index < nn) { + while (Index < nn && Index < NPT) { Sd->mPTLen[Index++] =3D 0; } =20 diff --git a/BaseTools/Source/C/Common/SimpleFileParsing.c b/BaseTools/Sour= ce/C/Common/SimpleFileParsing.c index 868c6b794b..209a0954b3 100644 --- a/BaseTools/Source/C/Common/SimpleFileParsing.c +++ b/BaseTools/Source/C/Common/SimpleFileParsing.c @@ -1,7 +1,7 @@ /** @file Generic but simple file parsing routines. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 @@ -1232,12 +1232,10 @@ GetHexChars ( { UINT32 Len; Len =3D 0; - while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) { + while (!EndOfFile (&mGlobals.SourceFile) && (Len < BufferLen)) { if (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) { - *Buffer =3D mGlobals.SourceFile.FileBufferPtr[0]; - Buffer++; + Buffer[Len] =3D mGlobals.SourceFile.FileBufferPtr[0]; Len++; - BufferLen--; mGlobals.SourceFile.FileBufferPtr++; } else { break; @@ -1246,8 +1244,8 @@ GetHexChars ( // // Null terminate if we can // - if ((Len > 0) && (BufferLen > 0)) { - *Buffer =3D 0; + if ((Len > 0) && (Len < BufferLen)) { + Buffer[Len] =3D 0; } =20 return Len; --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel