Skip to content

curl not detecting corrupt compressed data as an error #23615

Closed

Description

@piru

I did this

libcurl doesn't consider invalid compressed data as an error. This appears to be somewhat by design for deflate and gzip, but surely brotli shouldn't behave in this way?

Consider these 3 different fake HTTP servers:

  1. echo -ne 'HTTP/1.1 200 OK\r\nContent-Encoding: deflate\r\nContent-Length: 4\r\n\r\nAAAA' | nc -l -p 9999
  2. echo -ne 'HTTP/1.1 200 OK\r\nContent-Encoding: gzip\r\nContent-Length: 1\r\n\r\nA' | nc -l -p 9999
  3. echo -ne 'HTTP/1.1 200 OK\r\nContent-Encoding: br\r\nContent-Length: 3\r\n\r\nAAA' | nc -l -p 9999

None of these are considered an error by curl --compressed http://localhost:9999/x -O and produce a 0 byte file.

For brotli the issue seems to be that when BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT occurs there is no way for the brotli_do_write to communicate that further data is necessary and if none is available this should be considered an error.

I expected the following

libcurl to behave more consistently with corrupt compressed data (at least with brotli). When data is corrupt error should be returned and no partial file created.

curl/libcurl version

curl HEAD

operating system

Any

Activity

  1. akasakariko commented on Oct 28, 2026

    @akasakariko
    Contributor

    I'd like to work on this

  2. added a commit that references this issue on Oct 29, 2026
    f789f35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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