Skip to content

C# library can enter infinite loop on decompression. #1339

@AlexC-CCL

Description

@AlexC-CCL

Hi,

I happened upon an odd bug when attempting to decompress data which was not a valid brotli stream using the C# library which caused my application to hang. I tracked the bug to this line:

The Read method will never return -1, it returns 0 on EoF (I think this is just a translation error from Java, this same issue is noted here:

// EOF is -1 in Java, but 0 in C#.
but didn't get changed for the other call) - if EoF is hit early in CopyBytes, an infinite loop is entered with the Read method returning 0 over and over and never triggering the exception as it should.

The fix should just be to change -1 to 0 - this correctly triggered the BrotliRuntimeException in my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions