Skip to content

[System.Private.Xml] Possible incorrect behavior in character counting ( maxCharsCount >= charsCount ) #111969

@dumprop

Description

@dumprop

Description

Hello! I decided to test System.Private.Xml module via fuzzing test.
After some time I found test case which fails Debug.Assert(maxCharsCount >= charsCount)

Image

Reproduction Steps

Download latest .NET v6.0.36 and build it in Debug mode (enable asserts), make reference in test project.
Test's project code:

using SharpFuzz;
using System.Xml;

Fuzzer.Run(stream =>
    {
        try
        {
            using (var xml = XmlReader.Create(stream))
            {
                while (xml.Read()) { }
            }
        }
        catch (XmlException) { }
    }
);

corpus_file_for_xml_crash.txt

In result, value of maxCharsCount is 80 and charsCount is 81 - that produce a crash

Expected behavior

No any crash, as usual

Actual behavior

Debug.Assert(maxCharsCount >= charsCount) is failed because 80 >= 81 is false

Regression?

No response

Known Workarounds

No response

Configuration

.NET v6.0.36 from github, Debug build (enable asserts), Linux Ubuntu x64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Xmlneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions