From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 05BCB81C96 for ; Mon, 28 Nov 2016 19:46:51 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 28 Nov 2016 19:46:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,714,1473145200"; d="scan'208";a="1065487121" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 28 Nov 2016 19:46:50 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 28 Nov 2016 19:46:49 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.96]) by shsmsx102.ccr.corp.intel.com ([169.254.2.239]) with mapi id 14.03.0248.002; Tue, 29 Nov 2016 11:45:39 +0800 From: "Zhu, Yonghong" To: "Gao, Liming" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools CommonLib: Update ReadMemoryFileLine() to read line in file scope Thread-Index: AQHSRuy2NeYEKBR3Uk+Ct2QzMFZW8qDvWB5A Date: Tue, 29 Nov 2016 03:45:39 +0000 Message-ID: References: <1480058554-10220-1-git-send-email-liming.gao@intel.com> In-Reply-To: <1480058554-10220-1-git-send-email-liming.gao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjczNzU1ZjYtNWYyNi00YjFmLWE3Y2QtZWRlZjcwMDYwZDQ5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjBMcGhmYjBJNXZVcVJ0NkNCOWdpR29Tc2VvZGdJMHN6dTg0RkViWFJpUG89In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools CommonLib: Update ReadMemoryFileLine() to read line in file scope X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2016 03:46:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Gao, Liming=20 Sent: Friday, November 25, 2016 3:23 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong Subject: [Patch] BaseTools CommonLib: Update ReadMemoryFileLine() to read l= ine in file scope https://bugzilla.tianocore.org/show_bug.cgi?id=3D255 Check CurrentFilePointer to make sure it not exceed the end of file. Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao --- BaseTools/Source/C/Common/MemoryFile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BaseTools/Source/C/Common/MemoryFile.c b/BaseTools/Source/C/Co= mmon/MemoryFile.c index 1d90688..ec27619 100644 --- a/BaseTools/Source/C/Common/MemoryFile.c +++ b/BaseTools/Source/C/Common/MemoryFile.c @@ -222,6 +222,9 @@ Returns: // Increment the current file pointer (include the 0x0A) // InputFile->CurrentFilePointer +=3D CharsToCopy + 1; + if (InputFile->CurrentFilePointer > InputFile->Eof) { + InputFile->CurrentFilePointer =3D InputFile->Eof; } CheckMemoryFileState (InputMemoryFile); =20 // --=20 2.8.0.windows.1