Gargantuan source files can be silently treated as being much smaller · Issue #12814 · dotnet/roslyn (original) (raw)
Version Used: 1.3.1.60616 and recent sync to master
Steps to Reproduce:
- Run the following script
string program = "class P { static void Main() { System.Console.WriteLine("hello"); } }"; string garbage = "@#%@#^@#^!#%#@$%@^";
File.WriteAllText("big.cs", program + garbage, Encoding.ASCII);
using (var s = File.OpenWrite("big.cs")) { s.SetLength((long)uint.MaxValue + 1 + program.Length); }
csc big.cs
Expected Behavior:
Compilation fails (either with a deliberate diagnostic that the stream is too long or with the correct errors that match the full text).
Actual Behavior:
Compilation succeeds as it only reads up to program.Length
due to unchecked cast of stream length to int
.