From 05b2f9c94e0c0b663ff2d2fb55397d8215eeb3f5 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Tue, 10 May 2016 18:51:44 +0800 Subject: [PATCH] MdeModulePkg/SetupBrowser: Clean the BufferValue for string before use 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 Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong Reviewed-by: Liming Gao --- MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c | 4 +++- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 4c4e51d2f9..56ae7b02c2 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1,7 +1,7 @@ /** @file Utility functions for UI presentation. -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -2044,6 +2044,7 @@ ProcessCallBackFunction ( ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth); if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) { + ZeroMem (Statement->BufferValue, Statement->StorageWidth); CopyMem (Statement->BufferValue, NewString, StrSize (NewString)); } else { CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth); @@ -2293,6 +2294,7 @@ ProcessRetrieveForQuestion ( ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth); if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) { + ZeroMem (Statement->BufferValue, Statement->StorageWidth); CopyMem (Statement->BufferValue, NewString, StrSize (NewString)); } else { CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth); diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index f649e04979..6b38547c5e 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -4100,6 +4100,7 @@ GetQuestionDefault ( ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth); if (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth) { + ZeroMem (Question->BufferValue, Question->StorageWidth); CopyMem (Question->BufferValue, NewString, StrSize (NewString)); } else { CopyMem (Question->BufferValue, NewString, Question->StorageWidth); @@ -4170,6 +4171,7 @@ GetQuestionDefault ( return EFI_NOT_FOUND; } if (Question->StorageWidth > StrSize (StrValue)) { + ZeroMem (Question->BufferValue, Question->StorageWidth); CopyMem (Question->BufferValue, StrValue, StrSize (StrValue)); } else { CopyMem (Question->BufferValue, StrValue, Question->StorageWidth); -- 2.39.5