From d6039b1d6e83345e7354029ce104f87e304a5a5c Mon Sep 17 00:00:00 2001 From: gikidy Date: Wed, 7 Jan 2009 09:45:18 +0000 Subject: Fix memory overflow. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7203 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/BasePrintLib/PrintLibInternal.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'MdePkg/Library/BasePrintLib/PrintLibInternal.c') diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index d87513042e..05e3ed501d 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -77,11 +77,17 @@ BasePrintLibFillBuffer ( ) { INTN Index; - - for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { - *Buffer = (CHAR8) Character; - *(Buffer + 1) = (CHAR8) (Character >> 8); - Buffer += Increment; + if(Increment != 1) { + for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { + *Buffer = (CHAR8) Character; + *(Buffer + 1) = (CHAR8) (Character >> 8); + } + Buffer += Increment; + } else { + for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { + *Buffer = (CHAR8) Character; + } + Buffer += Increment; } return Buffer; } -- cgit v1.2.3