From 46e8b4b4d3376742b9f54a02460df2ff23b0d2ac Mon Sep 17 00:00:00 2001 From: vit9696 Date: Wed, 20 May 2020 10:24:05 +0300 Subject: [PATCH] Build: Fix some svace analysis issues --- Library/OcBootManagementLib/DmgBootSupport.c | 11 ++++++++++- Library/OcRtcLib/AppleRtcRam.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Library/OcBootManagementLib/DmgBootSupport.c b/Library/OcBootManagementLib/DmgBootSupport.c index e9818509..f7cc4e69 100644 --- a/Library/OcBootManagementLib/DmgBootSupport.c +++ b/Library/OcBootManagementLib/DmgBootSupport.c @@ -226,6 +226,7 @@ InternalFindFirstDmgFileName ( EFI_FILE_INFO *FileInfo; BOOLEAN NoFile; UINTN ExtOffset; + UINTN Length; INTN Result; ASSERT (Directory != NULL); @@ -239,7 +240,15 @@ InternalFindFirstDmgFileName ( continue; } - ExtOffset = (StrLen (FileInfo->FileName) - L_STR_LEN (L".dmg")); + // + // Discard filenames that do not contain characters prior to .dmg extension. + // + Length = StrLen (FileInfo->FileName); + if (Length <= L_STR_LEN (L".dmg")) { + continue; + } + + ExtOffset = Length - L_STR_LEN (L".dmg"); Result = StrCmp (&FileInfo->FileName[ExtOffset], L".dmg"); if (Result == 0) { if (FileNameLen != NULL) { diff --git a/Library/OcRtcLib/AppleRtcRam.c b/Library/OcRtcLib/AppleRtcRam.c index 0c41aebd..a255ad08 100644 --- a/Library/OcRtcLib/AppleRtcRam.c +++ b/Library/OcRtcLib/AppleRtcRam.c @@ -246,7 +246,7 @@ AppleRtcRamReset ( UINTN Index; UINT8 Buffer[APPLE_RTC_TOTAL_SIZE]; - ZeroMem (Buffer, sizeof (APPLE_RTC_TOTAL_SIZE)); + ZeroMem (Buffer, sizeof (Buffer)); for (Index = APPLE_RTC_CHECKSUM_START; Index < APPLE_RTC_CORE_SIZE; ++Index) { Status = SyncRtcWaitForReady ();