From d63d5884d7c2f7660175161187ce90852bc2a891 Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Wed, 24 Jul 2024 00:03:22 +0200 Subject: ShellPkg/UefiShellLib: Only write value if successful conversion The ShellConvertStringToUint64() function documentation says: "Upon a successful return the value of the conversion." So do not write any value if the conversion failed. Signed-off-by: Tormod Volden --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index a512c2c251..9dde9fddfa 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -4234,15 +4234,17 @@ ShellConvertStringToUint64 ( Status = InternalShellStrDecimalToUint64 (Walker, &RetVal, StopAtSpace); } - if ((Value == NULL) && !EFI_ERROR (Status)) { - return (EFI_NOT_FOUND); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; } - if (Value != NULL) { - *Value = RetVal; + if (Value == NULL) { + return EFI_NOT_FOUND; } - return (Status); + *Value = RetVal; + + return EFI_SUCCESS; } /** -- cgit