]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/FileHandleWrappers.c
ShellPkg: Standardized HP Copyright Message String
[mirror_edk2.git] / ShellPkg / Application / Shell / FileHandleWrappers.c
index ef8293c1de511914e690d5b1dc3028e6a2585a9e..984cd36957af6107b4209f231e8d521a696f5f4e 100644 (file)
@@ -2,8 +2,8 @@
   EFI_FILE_PROTOCOL wrappers for other items (Like Environment Variables,\r
   StdIn, StdOut, StdErr, etc...).\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
-  Copyright (c) 2013, Hewlett-Packard Development Company, L.P.\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -417,7 +417,7 @@ FileInterfaceStdInRead(
     gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
     Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
     if (EFI_ERROR (Status)) {\r
-      continue;\r
+      break;\r
     }\r
 \r
     //\r
@@ -509,21 +509,20 @@ FileInterfaceStdInRead(
         if (StrStr(CurrentString + TabPos, L":") == NULL) {\r
           Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);\r
           if (Cwd != NULL) {\r
-            StrCpy(TabStr, Cwd);\r
+            StrnCpy(TabStr, Cwd, (*BufferSize)/sizeof(CHAR16) - 1);\r
             if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos) == L'\\' ) {\r
               TabStr[StrLen(TabStr)-1] = CHAR_NULL;\r
             }\r
             StrnCat(TabStr, CurrentString + TabPos, (StringLen - TabPos) * sizeof (CHAR16));\r
           } else {\r
-            StrCpy(TabStr, L"");\r
+            *TabStr = CHAR_NULL;\r
             StrnCat(TabStr, CurrentString + TabPos, (StringLen - TabPos) * sizeof (CHAR16));\r
           }\r
         } else {\r
-          StrCpy(TabStr, CurrentString + TabPos);\r
+          StrnCpy(TabStr, CurrentString + TabPos, (*BufferSize)/sizeof(CHAR16) - 1);\r
         }\r
-        StrCat(TabStr, L"*");\r
+        StrnCat(TabStr, L"*", (*BufferSize)/sizeof(CHAR16) - 1 - StrLen(TabStr));\r
         FoundFileList = NULL;\r
-//        TabStr = PathCleanUpDirectories(TabStr);\r
         Status  = ShellInfoObject.NewEfiShellProtocol->FindFiles(TabStr, &FoundFileList);\r
         for ( TempStr = CurrentString\r
             ; *TempStr == L' '\r
@@ -849,7 +848,7 @@ FileInterfaceStdInRead(
   //\r
   ASSERT(FoundFileList == NULL);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 //\r
@@ -973,7 +972,7 @@ FileInterfaceEnvClose(
     Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);\r
   }\r
   \r
-  if (!EFI_ERROR(Status)) {\r
+  if (!EFI_ERROR(Status) && NewBuffer != NULL) {\r
     \r
     if (StrSize(NewBuffer) > 6)\r
     {\r
@@ -1141,6 +1140,7 @@ CreateFileInterfaceEnv(
   )\r
 {\r
   EFI_FILE_PROTOCOL_ENVIRONMENT  *EnvFileInterface;\r
+  UINTN                          EnvNameSize;\r
 \r
   if (EnvName == NULL) {\r
     return (NULL);\r
@@ -1149,7 +1149,8 @@ CreateFileInterfaceEnv(
   //\r
   // Get some memory\r
   //\r
-  EnvFileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_ENVIRONMENT)+StrSize(EnvName));\r
+  EnvNameSize = StrSize(EnvName);\r
+  EnvFileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_ENVIRONMENT)+EnvNameSize);\r
   if (EnvFileInterface == NULL){\r
     return (NULL);\r
   }\r
@@ -1167,8 +1168,8 @@ CreateFileInterfaceEnv(
   EnvFileInterface->Flush       = FileInterfaceNopGeneric;\r
   EnvFileInterface->Delete      = FileInterfaceEnvDelete;\r
   EnvFileInterface->Read        = FileInterfaceEnvRead;\r
-\r
-  StrCpy(EnvFileInterface->Name, EnvName);\r
+  \r
+  CopyMem(EnvFileInterface->Name, EnvName, EnvNameSize);\r
 \r
   //\r
   // Assign the different members for Volatile and Non-Volatile variables\r