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 <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>
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Utility functions for UI presentation.
|
Utility functions for UI presentation.
|
||||||
|
|
||||||
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
|
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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);
|
ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth);
|
||||||
if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {
|
if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {
|
||||||
|
ZeroMem (Statement->BufferValue, Statement->StorageWidth);
|
||||||
CopyMem (Statement->BufferValue, NewString, StrSize (NewString));
|
CopyMem (Statement->BufferValue, NewString, StrSize (NewString));
|
||||||
} else {
|
} else {
|
||||||
CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);
|
CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);
|
||||||
@ -2293,6 +2294,7 @@ ProcessRetrieveForQuestion (
|
|||||||
|
|
||||||
ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth);
|
ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth);
|
||||||
if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {
|
if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {
|
||||||
|
ZeroMem (Statement->BufferValue, Statement->StorageWidth);
|
||||||
CopyMem (Statement->BufferValue, NewString, StrSize (NewString));
|
CopyMem (Statement->BufferValue, NewString, StrSize (NewString));
|
||||||
} else {
|
} else {
|
||||||
CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);
|
CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);
|
||||||
|
@ -4100,6 +4100,7 @@ GetQuestionDefault (
|
|||||||
|
|
||||||
ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth);
|
ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth);
|
||||||
if (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth) {
|
if (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth) {
|
||||||
|
ZeroMem (Question->BufferValue, Question->StorageWidth);
|
||||||
CopyMem (Question->BufferValue, NewString, StrSize (NewString));
|
CopyMem (Question->BufferValue, NewString, StrSize (NewString));
|
||||||
} else {
|
} else {
|
||||||
CopyMem (Question->BufferValue, NewString, Question->StorageWidth);
|
CopyMem (Question->BufferValue, NewString, Question->StorageWidth);
|
||||||
@ -4170,6 +4171,7 @@ GetQuestionDefault (
|
|||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
if (Question->StorageWidth > StrSize (StrValue)) {
|
if (Question->StorageWidth > StrSize (StrValue)) {
|
||||||
|
ZeroMem (Question->BufferValue, Question->StorageWidth);
|
||||||
CopyMem (Question->BufferValue, StrValue, StrSize (StrValue));
|
CopyMem (Question->BufferValue, StrValue, StrSize (StrValue));
|
||||||
} else {
|
} else {
|
||||||
CopyMem (Question->BufferValue, StrValue, Question->StorageWidth);
|
CopyMem (Question->BufferValue, StrValue, Question->StorageWidth);
|
||||||
|
Reference in New Issue
Block a user