]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SetupBrowser: Clean the BufferValue for string before use
authorDandan Bi <dandan.bi@intel.com>
Tue, 10 May 2016 10:51:44 +0000 (18:51 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 17 May 2016 06:38:05 +0000 (14:38 +0800)
When copy new string content to BufferValue, need to clean the
BufferValue firstly, or the BufferValue may contain some
content that doesn't belong to the new string.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c

index 4c4e51d2f985f1e244ab54ce99befd548189caca..56ae7b02c21dac61bcbb92c5b2420594e84f3ac8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Utility functions for UI presentation.\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -2044,6 +2044,7 @@ ProcessCallBackFunction (
 \r
         ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth);\r
         if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {\r
+          ZeroMem (Statement->BufferValue, Statement->StorageWidth);\r
           CopyMem (Statement->BufferValue, NewString, StrSize (NewString));\r
         } else {\r
           CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);\r
@@ -2293,6 +2294,7 @@ ProcessRetrieveForQuestion (
 \r
     ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth);\r
     if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {\r
+      ZeroMem (Statement->BufferValue, Statement->StorageWidth);\r
       CopyMem (Statement->BufferValue, NewString, StrSize (NewString));\r
     } else {\r
       CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);\r
index f649e0497927ebd3aca7016362c28ea39c625a0a..6b38547c5e7988a8018cb40e7bd5eb0f161ef180 100644 (file)
@@ -4100,6 +4100,7 @@ GetQuestionDefault (
 \r
         ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth);\r
         if (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth) {\r
+          ZeroMem (Question->BufferValue, Question->StorageWidth);\r
           CopyMem (Question->BufferValue, NewString, StrSize (NewString));\r
         } else {\r
           CopyMem (Question->BufferValue, NewString, Question->StorageWidth);\r
@@ -4170,6 +4171,7 @@ GetQuestionDefault (
             return EFI_NOT_FOUND;\r
           }\r
           if (Question->StorageWidth > StrSize (StrValue)) {\r
+            ZeroMem (Question->BufferValue, Question->StorageWidth);\r
             CopyMem (Question->BufferValue, StrValue, StrSize (StrValue));\r
           } else {\r
             CopyMem (Question->BufferValue, StrValue, Question->StorageWidth);\r