`multi_decompress_to_buffer([])` terminates the process with SIGFPE

Open Beginner friendly
#335 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, python
Domain
api, backend

Research direction

Start at c-ext/decompressor.c:1237 and run the provided empty-list reproducer, preferably with UBSan, to inspect the division-by-zero path. Check nearby decompression tests and add coverage for an empty frame list; done means it returns an empty result or raises an exception without terminating the interpreter.

Written by the indexing model from the issue text.

Description

I've been fuzzing Python C extension modules for a small research project, and this one came up.
It reproduces with the binary wheel from a plain pip install zstandard.

Versions

zstandard 0.25.0 C backend, CPython 3.12.3, Ubuntu 24.04 x86_64, glibc 2.39.

Reproducer
import zstandard

zstandard.ZstdDecompressor().multi_decompress_to_buffer([])

An UBSan build identifies a division by zero at c-ext/decompressor.c:1237.

I would expect an empty frame list to return an empty result or raise an exception rather than terminate the interpreter.

Dominant language
C
Stars
642
Forks
116
Avg merge
1d 14h
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from indygreg/python-zstandard

All issues in indygreg/python-zstandard

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.