From cf4d2b0594a7af4a5ff39ffd4fe5cfb0c5577a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Petryka?= <35800402+MichalPetryka@users.noreply.github.com> Date: Fri, 20 Dec 2024 05:45:08 +0100 Subject: [PATCH] Fix OSEncoding math overflow (#110796) Discovered by @GrabYourPitchforks --- src/libraries/Common/src/System/Text/OSEncoding.Windows.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs b/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs index fc3f866ec96a6..4d3d91e423e45 100644 --- a/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs +++ b/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs @@ -168,7 +168,7 @@ public override int GetMaxCharCount(int byteCount) { ArgumentOutOfRangeException.ThrowIfNegative(byteCount); - long charCount = byteCount * 4; // Max possible value for all encodings + long charCount = (long)byteCount * 4; // Max possible value for all encodings if (charCount > 0x7fffffff) throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow);