You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the unlikely scenario where the console's input is using a custom encoding, and the GetMaxCharCount returns a large value, this can lead to a large stack allocation.
Program to reproduce (works on macOS):
using System.Text;namespaceFoo{classProgram{staticvoidMain(){
Console.InputEncoding =new CustomEncoding();
Console.ReadKey(true);}}publicclassCustomEncoding:UTF8Encoding{publicoverrideintGetMaxCharCount(intbyteCount)=>int.MaxValue;}}
The value being fed in to the stackalloc's length should be guarded since it is dependent on external factors, in this case the encoding used by stdin.
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.
Issue Details
In the unlikely scenario where the console's input is using a custom encoding, and the GetMaxCharCount returns a large value, this can lead to a large stack allocation.
Program to reproduce (works on macOS):
using System.Text;namespaceFoo{classProgram{staticvoidMain(){
Console.InputEncoding =new CustomEncoding();
Console.ReadKey(true);}}publicclassCustomEncoding:UTF8Encoding{publicoverrideintGetMaxCharCount(intbyteCount)=>int.MaxValue;}}
The value being fed in to the stackalloc's length should be guarded since it is dependent on external factors, in this case the encoding used by stdin.
ghost
removed
untriaged
New issue has not been triaged by the area owner
in-pr
There is an active PR which will close this issue when it is merged
labels
Apr 23, 2022
In the unlikely scenario where the console's input is using a custom encoding, and the
GetMaxCharCount
returns a large value, this can lead to a large stack allocation.Program to reproduce (works on macOS):
The
stackalloc
is here:runtime/src/libraries/System.Console/src/System/IO/StdInReader.cs
Line 53 in 0e18cfd
The value being fed in to the
stackalloc
's length should be guarded since it is dependent on external factors, in this case the encoding used by stdin.The text was updated successfully, but these errors were encountered: