From e74c427978b5fb92621ffbf44a11c703b18a1233 Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Thu, 20 Aug 2015 00:22:16 +0000 Subject: [PATCH] Validate the input namespace field to avoid assert. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18239 6f19259b-4bc3-4df7-8a09-765794883524 --- .../HiiDatabaseDxe/ConfigKeywordHandler.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c index 4cf803c54f..eac7717053 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c @@ -2850,8 +2850,17 @@ EfiConfigKeywordHandlerSetData ( Status = ExtractNameSpace (StringPtr, &NameSpace, &NextStringPtr); if (EFI_ERROR (Status)) { *ProgressErr = KEYWORD_HANDLER_MALFORMED_STRING; - return Status; + goto Done; } + // + // 1.1 Check whether the input namespace is valid. + // + if (AsciiStrnCmp(NameSpace, UEFI_CONFIG_LANG, AsciiStrLen (UEFI_CONFIG_LANG)) != 0) { + *ProgressErr = KEYWORD_HANDLER_UNDEFINED_PROCESSING_ERROR; + Status = EFI_INVALID_PARAMETER; + goto Done; + } + StringPtr = NextStringPtr; // @@ -3124,7 +3133,14 @@ EfiConfigKeywordHandlerGetData ( *ProgressErr = KEYWORD_HANDLER_NAMESPACE_ID_NOT_FOUND; return Status; } - + // + // 1.1 Check whether the input namespace is valid. + // + if (AsciiStrnCmp(NameSpace, UEFI_CONFIG_LANG, AsciiStrLen (UEFI_CONFIG_LANG)) != 0) { + *ProgressErr = KEYWORD_HANDLER_UNDEFINED_PROCESSING_ERROR; + return EFI_INVALID_PARAMETER; + } + if (KeywordString != NULL) { // // Use temp string to avoid changing input string buffer.