From: Liming Gao Date: Fri, 25 Nov 2016 06:57:31 +0000 (+0800) Subject: BaseTools CommonLib: Update ReadMemoryFileLine() to read line in file scope X-Git-Tag: edk2-stable201903~5049 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=60a5378208f8b60e0a04ac724a639ad19158e778 BaseTools CommonLib: Update ReadMemoryFileLine() to read line in file scope https://bugzilla.tianocore.org/show_bug.cgi?id=255 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 Reviewed-by: Yonghong Zhu --- diff --git a/BaseTools/Source/C/Common/MemoryFile.c b/BaseTools/Source/C/Common/MemoryFile.c index 1d9068822e..ec27619abb 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 += CharsToCopy + 1; + if (InputFile->CurrentFilePointer > InputFile->Eof) { + InputFile->CurrentFilePointer = InputFile->Eof; + } CheckMemoryFileState (InputMemoryFile); //