From 1d64506f05e320f47e7170fa7d69ff89a953ce7b Mon Sep 17 00:00:00 2001 From: Oliver Smith-Denny Date: Thu, 3 Oct 2024 10:30:45 -0700 Subject: [PATCH] ShellPkg: DynamicCommand: CodeQL Fixes Includes changes across the module for the following CodeQL rules: - cpp/comparison-with-wider-type - cpp/overflow-buffer - cpp/redundant-null-check-param - cpp/uselesstest Co-authored-by: Taylor Beebe Signed-off-by: Oliver Smith-Denny --- ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c | 4 ++++ ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c b/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c index b4e88e7635..37afefd80b 100644 --- a/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c +++ b/ShellPkg/DynamicCommand/HttpDynamicCommand/Http.c @@ -1815,6 +1815,10 @@ DownloadFile ( Context->Uri, StrLen (Context->Uri) ); + if (DownloadUrl == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } PRINT_HII (STRING_TOKEN (STR_HTTP_DOWNLOADING), DownloadUrl); diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c index 7e5c73b3da..a60d6be2d6 100644 --- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c +++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c @@ -395,7 +395,11 @@ RunTftp ( } RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2); - ASSERT (RemoteFilePath != NULL); + if (RemoteFilePath == NULL) { + ASSERT (RemoteFilePath != NULL); + goto Error; + } + FilePathSize = StrLen (RemoteFilePath) + 1; AsciiRemoteFilePath = AllocatePool (FilePathSize); if (AsciiRemoteFilePath == NULL) {