]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
This patch replaces StrCpy with StrnCpy or refactors out the usage of StrCpy through...
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Rm.c
index dbf980a60c30845791ed1da4be5140a1591250c7..6cc5dcf69107a91a6ea98f0b6aa56a5fa5f4cf81 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for attrib shell level 2 function.\r
 \r
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<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
@@ -39,6 +39,7 @@ IsDirectoryEmpty (
 \r
   RetVal = TRUE;\r
   NoFile = FALSE;\r
+  FileInfo = NULL;\r
 \r
   for (FileHandleFindFirstFile(FileHandle, &FileInfo)\r
     ;  !NoFile\r
@@ -76,6 +77,7 @@ CascadeDelete(
   EFI_STATUS            Status;\r
   SHELL_PROMPT_RESPONSE *Resp;\r
   CHAR16                *TempName;\r
+  UINTN                 NewSize;\r
 \r
   Resp                  = NULL;\r
   ShellStatus           = SHELL_SUCCESS;\r
@@ -92,7 +94,6 @@ CascadeDelete(
       if (!Quiet) {\r
         Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_RM_LOG_DELETE_CONF), gShellLevel2HiiHandle, Node->FullName);\r
         Status = ShellPromptForResponse(ShellPromptResponseTypeYesNo, NULL, (VOID**)&Resp);\r
-        ASSERT_EFI_ERROR(Status);\r
         ASSERT(Resp != NULL);\r
         if (EFI_ERROR(Status) || *Resp != ShellPromptResponseYes) {\r
           SHELL_FREE_NON_NULL(Resp);\r
@@ -125,13 +126,14 @@ CascadeDelete(
           //\r
           // Update the node filename to have full path with file system identifier\r
           //\r
-          TempName = AllocateZeroPool(StrSize(Node->FullName) + StrSize(Node2->FullName));\r
+          NewSize = StrSize(Node->FullName) + StrSize(Node2->FullName);\r
+          TempName = AllocateZeroPool(NewSize);\r
           if (TempName == NULL) {\r
             ShellStatus = SHELL_OUT_OF_RESOURCES;\r
           } else {\r
-            StrCpy(TempName, Node->FullName);\r
+            StrnCpy(TempName, Node->FullName, NewSize/sizeof(CHAR16) -1);\r
             TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL;\r
-            StrCat(TempName, Node2->FullName);\r
+            StrnCat(TempName, Node2->FullName, NewSize/sizeof(CHAR16) -1 - StrLen(TempName));\r
             FreePool((VOID*)Node2->FullName);\r
             Node2->FullName = TempName;\r
 \r
@@ -144,7 +146,7 @@ CascadeDelete(
         if (!EFI_ERROR(Node2->Status)) {\r
           ShellStatus = CascadeDelete(Node2, Quiet);\r
         } else if (ShellStatus == SHELL_SUCCESS) {\r
-          ShellStatus = Node2->Status;\r
+          ShellStatus = (SHELL_STATUS)(Node2->Status&(~0x80000000));\r
         }\r
         if (ShellStatus != SHELL_SUCCESS) {\r
           if (List!=NULL) {\r
@@ -175,7 +177,9 @@ CascadeDelete(
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR), gShellLevel2HiiHandle, Status);\r
     return (SHELL_ACCESS_DENIED);\r
   } else {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_COMP), gShellLevel2HiiHandle);\r
+    if (!Quiet) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_COMP), gShellLevel2HiiHandle);\r
+    }\r
     return (SHELL_SUCCESS);\r
   }\r
 }\r