diff options
author | Jim Dailey <Jim_Dailey@Dell.com> | 2016-02-10 13:17:56 -0800 |
---|---|---|
committer | Jaben Carsey <jaben.carsey@intel.com> | 2016-02-10 13:17:56 -0800 |
commit | 1095b4323dab2e64e71bf7896ea88a0eb5d64706 (patch) | |
tree | 970b853045f740ae6b28985cf30d5880c596bf01 /ShellPkg | |
parent | 62989e0bd2bf9bb22e15306d41feb6f677a6b4af (diff) | |
download | edk2-platforms-1095b4323dab2e64e71bf7896ea88a0eb5d64706.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>
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);
|