diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs index dd460b178945f6..2c173244bb83de 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs @@ -59,12 +59,6 @@ private static void LoadAppLocalIcu(string icuSuffixAndVersion, bool suffixWithS if (indexOfSeparator >= 0) { icuSuffix = icuSuffixAndVersion.AsSpan().Slice(0, indexOfSeparator); - - if (icuSuffix.Length > 35) - { - Environment.FailFast($"The resolved \"{icuSuffix.ToString()}\" suffix from System.Globalization.AppLocalIcu switch has to be < 20 chars long."); - } - version = icuSuffixAndVersion.AsSpan().Slice(icuSuffix.Length + 1); } else @@ -72,11 +66,6 @@ private static void LoadAppLocalIcu(string icuSuffixAndVersion, bool suffixWithS version = icuSuffixAndVersion; } - if (version.Length > 33) - { - Environment.FailFast($"The resolved version \"{version.ToString()}\" from System.Globalization.AppLocalIcu switch has to be < 33 chars long."); - } - if (suffixWithSeparator) { icuSuffix = string.Concat(icuSuffix, "."); diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c index 093188b964a0e9..7fa6dd6fd8ac16 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c @@ -432,10 +432,23 @@ void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char* char symbolVersion[MaxICUVersionStringWithSuffixLength + 1]=""; char symbolSuffix[SYMBOL_CUSTOM_SUFFIX_SIZE]=""; + if (strlen(version) > (size_t)MaxICUVersionStringLength) + { + fprintf(stderr, "The resolved version \"%s\" from System.Globalization.AppLocalIcu switch has to be < %zu chars long.\n", version, (size_t)MaxICUVersionStringLength); + abort(); + } + sscanf(version, "%d.%d.%d", &major, &minor, &build); if (suffix != NULL) { + size_t suffixAllowedSize = SYMBOL_CUSTOM_SUFFIX_SIZE - 2; // SYMBOL_CUSTOM_SUFFIX_SIZE considers `_` and `\0`. + if (strlen(suffix) > suffixAllowedSize) + { + fprintf(stderr, "The resolved suffix \"%s\" from System.Globalization.AppLocalIcu switch has to be < %zu chars long.\n", suffix, suffixAllowedSize); + abort(); + } + assert(strlen(suffix) + 1 <= SYMBOL_CUSTOM_SUFFIX_SIZE); #if defined(TARGET_WINDOWS)