From b063a20c61e110e0b3f976ddf3f1f02ad424a352 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sun, 2 Apr 2023 13:21:03 +0300 Subject: [PATCH] MdePkg: Fix uninitialised access in SafeString --- MdePkg/Library/BaseLib/String.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c index 98e6d31463..45f1d76955 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -452,9 +452,14 @@ StrDecimalToUint64 ( IN CONST CHAR16 *String ) { - UINT64 Result; + UINT64 Result; + RETURN_STATUS Status; + + Status = StrDecimalToUint64S (String, (CHAR16 **)NULL, &Result); + if (RETURN_ERROR (Status)) { + return 0; + } - StrDecimalToUint64S (String, (CHAR16 **)NULL, &Result); return Result; } @@ -499,9 +504,14 @@ StrHexToUintn ( IN CONST CHAR16 *String ) { - UINTN Result; + UINTN Result; + RETURN_STATUS Status; + + Status = StrHexToUintnS (String, (CHAR16 **)NULL, &Result); + if (RETURN_ERROR (Status)) { + return 0; + } - StrHexToUintnS (String, (CHAR16 **)NULL, &Result); return Result; } @@ -546,9 +556,14 @@ StrHexToUint64 ( IN CONST CHAR16 *String ) { - UINT64 Result; + UINT64 Result; + RETURN_STATUS Status; + + Status = StrHexToUint64S (String, (CHAR16 **)NULL, &Result); + if (RETURN_ERROR (Status)) { + return 0; + } - StrHexToUint64S (String, (CHAR16 **)NULL, &Result); return Result; }