From 60a5378208f8b60e0a04ac724a639ad19158e778 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Fri, 25 Nov 2016 14:57:31 +0800 Subject: 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 --- BaseTools/Source/C/Common/MemoryFile.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'BaseTools/Source/C') 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); // -- cgit v1.2.3