diff options
author | Jim Dailey <Jim_Dailey@Dell.com> | 2016-02-10 13:17:56 -0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-13 20:41:56 +0800 |
commit | 2df01a61eb6e76b73906fa4867e5924819c37f5a (patch) | |
tree | cc711b243b96dd4cb0e003d54e63eeaa236f305e /ShellPkg | |
parent | 9cfd3a1241864345771be247c531a17de9694610 (diff) | |
download | edk2-platforms-2df01a61eb6e76b73906fa4867e5924819c37f5a.tar.xz |
ShellPkg: complete previous incomplete patch
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jim Dailey <Jim_Dailey@Dell.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 1095b4323dab2e64e71bf7896ea88a0eb5d64706)
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index dac0524fcb..abff0d3114 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -4176,43 +4176,27 @@ ShellFileHandleReadLine( //
// if we have space save it...
//
- if ((CountSoFar + 1) * CharSize < *Size){
+ if ((CountSoFar+1)*sizeof(CHAR16) < *Size){
ASSERT(Buffer != NULL);
- if (*Ascii) {
- ((CHAR8*)Buffer)[CountSoFar] = (CHAR8) CharBuffer;
- ((CHAR8*)Buffer)[CountSoFar+1] = '\0';
- }
- else {
- ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;
- ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;
- }
+ ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;
+ ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;
}
}
//
// if we ran out of space tell when...
//
- if (Status != EFI_END_OF_FILE){
- if ((CountSoFar + 1) * CharSize > *Size){
- *Size = (CountSoFar + 1) * CharSize;
- if (!Truncate) {
- gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
- } else {
- DEBUG((DEBUG_WARN, "The line was truncated in ShellFileHandleReadLine"));
- }
- return (EFI_BUFFER_TOO_SMALL);
- }
-
- if (*Ascii) {
- if (CountSoFar && ((CHAR8*)Buffer)[CountSoFar - 1] == '\r') {
- ((CHAR8*)Buffer)[CountSoFar - 1] = '\0';
- }
- }
- else {
- if (CountSoFar && Buffer[CountSoFar - 1] == L'\r') {
- Buffer[CountSoFar - 1] = CHAR_NULL;
- }
+ if ((CountSoFar+1)*sizeof(CHAR16) > *Size){
+ *Size = (CountSoFar+1)*sizeof(CHAR16);
+ if (!Truncate) {
+ gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
+ } else {
+ DEBUG((DEBUG_WARN, "The line was truncated in ShellFileHandleReadLine"));
}
+ return (EFI_BUFFER_TOO_SMALL);
+ }
+ while(Buffer[StrLen(Buffer)-1] == L'\r') {
+ Buffer[StrLen(Buffer)-1] = CHAR_NULL;
}
return (Status);
|