From 132f1beae35162e24675912b55b2f34f9d473cbc Mon Sep 17 00:00:00 2001 From: AJFISH Date: Fri, 18 Dec 2009 20:49:28 +0000 Subject: Fix a bug with the shell cp command. When searching for a / it was possible to lose a directory level. I changed the code to add a missing / if needed and not search backwards for one. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9578 6f19259b-4bc3-4df7-8a09-765794883524 --- UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.c b/UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.c index b46c9dce97..a0c75f578b 100644 --- a/UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.c +++ b/UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.c @@ -1895,7 +1895,7 @@ Returns: } else { Status = gBS->AllocatePool ( EfiBootServicesData, - AsciiStrLen (PrivateFile->FileName) + 1 + StrLen (NewFileInfo->FileName) + 1, + AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1, (VOID **)&NewFileName ); @@ -1905,8 +1905,11 @@ Returns: AsciiStrCpy (NewFileName, PrivateRoot->FilePath); AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName); - while (AsciiFilePtr > NewFileName && AsciiFilePtr[-1] != '/') { - AsciiFilePtr--; + if ((AsciiFilePtr[-1] != '/') && (NewFileInfo->FileName[0] != '/')) { + // make sure there is a / between Root FilePath and NewFileInfo Filename + AsciiFilePtr[0] = '/'; + AsciiFilePtr[1] = '\0'; + AsciiFilePtr++; } UnicodeFilePtr = NewFileInfo->FileName; } @@ -2091,7 +2094,6 @@ Returns: } UnixStatus = PrivateFile->UnixThunk->Chmod (NewFileName, NewAttr); - if (UnixStatus != 0) { Status = EFI_DEVICE_ERROR; } -- cgit v1.2.3