diff options
author | Jaben Carsey <jaben.carsey@intel.com> | 2016-02-10 08:56:33 -0800 |
---|---|---|
committer | Jaben Carsey <jaben.carsey@intel.com> | 2016-02-10 08:56:33 -0800 |
commit | 3a01358bdb03284adf73de9a79638005f7851ac3 (patch) | |
tree | 3844b06b38abfab016da53f64db95518e8e71655 /ShellPkg | |
parent | 2dda8a12329700f9026236d83be4de9e5369f97f (diff) | |
parent | 7d0f92e8fd68e1f1242f36c203400be23954d563 (diff) | |
download | edk2-platforms-3a01358bdb03284adf73de9a79638005f7851ac3.tar.xz |
Merge branch 'master' of https://github.com/tianocore/edk2
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index abff0d3114..dac0524fcb 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -4176,27 +4176,43 @@ ShellFileHandleReadLine( //
// if we have space save it...
//
- if ((CountSoFar+1)*sizeof(CHAR16) < *Size){
+ if ((CountSoFar + 1) * CharSize < *Size){
ASSERT(Buffer != NULL);
- ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;
- ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;
+ if (*Ascii) {
+ ((CHAR8*)Buffer)[CountSoFar] = (CHAR8) CharBuffer;
+ ((CHAR8*)Buffer)[CountSoFar+1] = '\0';
+ }
+ else {
+ ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;
+ ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;
+ }
}
}
//
// if we ran out of space tell when...
//
- 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"));
+ 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;
+ }
}
- return (EFI_BUFFER_TOO_SMALL);
- }
- while(Buffer[StrLen(Buffer)-1] == L'\r') {
- Buffer[StrLen(Buffer)-1] = CHAR_NULL;
}
return (Status);
|