From 5fcb82d548cc4b6d906598bc0a1b0293737211cf Mon Sep 17 00:00:00 2001 From: kaybelev Date: Thu, 18 Jan 2024 11:38:19 +0300 Subject: [PATCH 1/9] Fixed error: . The error was detected using the Svace analyzer maded by ISP RAS. --- src/coreclr/pal/src/file/filetime.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/pal/src/file/filetime.cpp b/src/coreclr/pal/src/file/filetime.cpp index 2500d234d8b65a..de808c7e10394e 100644 --- a/src/coreclr/pal/src/file/filetime.cpp +++ b/src/coreclr/pal/src/file/filetime.cpp @@ -263,6 +263,7 @@ BOOL PALAPI FileTimeToSystemTime( CONST FILETIME * lpFileTime, #else /* HAVE_GMTIME_R */ UnixSystemTime = gmtime( &UnixFileTime ); #endif /* HAVE_GMTIME_R */ + if (!UnixSystemTime) return FALSE; /* Convert unix system time to Windows system time. */ lpSystemTime->wDay = (WORD)UnixSystemTime->tm_mday; From 09fd2f5c1a79c5dbad0993b81275e81830e26eda Mon Sep 17 00:00:00 2001 From: kaybelev Date: Thu, 18 Jan 2024 13:55:15 +0300 Subject: [PATCH 2/9] Fixed error: . The error was detected using the Svace analyzer maded by ISP RAS. --- src/coreclr/pal/src/thread/process.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index f9f2703cf4b23d..4fa42b0aa961b6 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2821,6 +2821,7 @@ CorUnix::InitializeProcessCommandLine( if (lpwstrFullPath) { LPWSTR lpwstr = PAL_wcsrchr(lpwstrFullPath, '/'); + if (!lpwstr) {palError = ERROR_INTERNAL_ERROR; goto exit;} lpwstr[0] = '\0'; size_t n = PAL_wcslen(lpwstrFullPath) + 1; From 3369cbecf4d5ead558f974e18748cf5b564ea309 Mon Sep 17 00:00:00 2001 From: kaybelev Date: Thu, 18 Jan 2024 14:08:39 +0300 Subject: [PATCH 3/9] Fixed error: . The error was detected using the Svace analyzer maded by ISP RAS. --- .../src/System/Configuration/MgmtConfigurationRecord.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs index 31e148711d8db6..613a3158dfcd01 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs @@ -335,7 +335,7 @@ internal ConfigurationSection FindImmediateParentSection(ConfigurationSection se string configKey = section.SectionInformation.SectionName; SectionRecord sectionRecord = GetSectionRecord(configKey, false); - if (sectionRecord.HasLocationInputs) + if ((sectionRecord != null) && sectionRecord.HasLocationInputs) { SectionInput input = sectionRecord.LastLocationInput; Debug.Assert(input.HasResult, "input.HasResult"); From d32b505e9a7c666bb6f0db837b57cb80e0f60a2d Mon Sep 17 00:00:00 2001 From: kaybelev Date: Thu, 18 Jan 2024 15:39:43 +0300 Subject: [PATCH 4/9] Fixed error: . The error was detected using the Svace analyzer maded by ISP RAS. --- .../tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs index b119f3bce5e4f7..dfc21b015428ea 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs @@ -414,7 +414,7 @@ private uint LookupIbcMethodToken(MetadataType methodMetadataType, uint ibcToken if (method.Name == methodName) { EcmaMethod ecmaCandidateMethod = method as EcmaMethod; - if (method == null) + if (ecmaCandidateMethod == null) continue; MetadataReader metadataReader = ecmaCandidateMethod.MetadataReader; From 82d4ff27642c60b69418ea09b1f12c375fb5b6fa Mon Sep 17 00:00:00 2001 From: kaybelev <156906788+kaybelev@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:47:27 +0300 Subject: [PATCH 5/9] Update filetime.cpp --- src/coreclr/pal/src/file/filetime.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/coreclr/pal/src/file/filetime.cpp b/src/coreclr/pal/src/file/filetime.cpp index de808c7e10394e..d038c9f29eb595 100644 --- a/src/coreclr/pal/src/file/filetime.cpp +++ b/src/coreclr/pal/src/file/filetime.cpp @@ -263,8 +263,13 @@ BOOL PALAPI FileTimeToSystemTime( CONST FILETIME * lpFileTime, #else /* HAVE_GMTIME_R */ UnixSystemTime = gmtime( &UnixFileTime ); #endif /* HAVE_GMTIME_R */ - if (!UnixSystemTime) return FALSE; - + if (!UnixSystemTime) + { + ERROR( "gmtime failed.\n" ); + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + /* Convert unix system time to Windows system time. */ lpSystemTime->wDay = (WORD)UnixSystemTime->tm_mday; From 202117dfb9d3355f13ec09d16fcb01a8249bf80a Mon Sep 17 00:00:00 2001 From: kaybelev <156906788+kaybelev@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:59:19 +0300 Subject: [PATCH 6/9] Update process.cpp --- src/coreclr/pal/src/thread/process.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 4fa42b0aa961b6..b23eab001cca4e 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -2821,7 +2821,12 @@ CorUnix::InitializeProcessCommandLine( if (lpwstrFullPath) { LPWSTR lpwstr = PAL_wcsrchr(lpwstrFullPath, '/'); - if (!lpwstr) {palError = ERROR_INTERNAL_ERROR; goto exit;} + if (!lpwstr) + { + ERROR("Invalid full path\n"); + palError = ERROR_INTERNAL_ERROR; + goto exit; + } lpwstr[0] = '\0'; size_t n = PAL_wcslen(lpwstrFullPath) + 1; From 41ed1087207c3bad1f0e17aa47560194a7a955d0 Mon Sep 17 00:00:00 2001 From: kaybelev <156906788+kaybelev@users.noreply.github.com> Date: Fri, 19 Jan 2024 14:02:59 +0300 Subject: [PATCH 7/9] Update MgmtConfigurationRecord.cs --- .../src/System/Configuration/MgmtConfigurationRecord.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs index 613a3158dfcd01..ffbd9ec0b3846d 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs @@ -343,7 +343,7 @@ internal ConfigurationSection FindImmediateParentSection(ConfigurationSection se } else { - if (sectionRecord.HasIndirectLocationInputs) + if ((sectionRecord != null) && sectionRecord.HasIndirectLocationInputs) { Debug.Assert(IsLocationConfig, "Indirect location inputs exist only in location config record"); SectionInput input = sectionRecord.LastIndirectLocationInput; From 11e19ea29cfa6bfd8be730469d637e9bde94927b Mon Sep 17 00:00:00 2001 From: kaybelev <156906788+kaybelev@users.noreply.github.com> Date: Fri, 19 Jan 2024 14:48:49 +0300 Subject: [PATCH 8/9] Update src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs Co-authored-by: Jan Kotas --- .../src/System/Configuration/MgmtConfigurationRecord.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs index ffbd9ec0b3846d..3d5c24d8409221 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs @@ -335,7 +335,8 @@ internal ConfigurationSection FindImmediateParentSection(ConfigurationSection se string configKey = section.SectionInformation.SectionName; SectionRecord sectionRecord = GetSectionRecord(configKey, false); - if ((sectionRecord != null) && sectionRecord.HasLocationInputs) + Debug.Assert(sectionRecord != null); + if (sectionRecord.HasLocationInputs) { SectionInput input = sectionRecord.LastLocationInput; Debug.Assert(input.HasResult, "input.HasResult"); From a7282dfa8d68fe38d2aaecafbf712b288978f201 Mon Sep 17 00:00:00 2001 From: kaybelev <156906788+kaybelev@users.noreply.github.com> Date: Fri, 19 Jan 2024 14:49:33 +0300 Subject: [PATCH 9/9] Update src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs Co-authored-by: Jan Kotas --- .../src/System/Configuration/MgmtConfigurationRecord.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs index 3d5c24d8409221..4bcfe2a999fbbf 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs @@ -344,7 +344,7 @@ internal ConfigurationSection FindImmediateParentSection(ConfigurationSection se } else { - if ((sectionRecord != null) && sectionRecord.HasIndirectLocationInputs) + if (sectionRecord.HasIndirectLocationInputs) { Debug.Assert(IsLocationConfig, "Indirect location inputs exist only in location config record"); SectionInput input = sectionRecord.LastIndirectLocationInput;