python / python/cpython

wave.open raises EOFError instead of wave.Error for a truncated fmt chunk

Aperta
#153,692 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stdlib type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug description

wave.open(f, 'rb') is documented to raise wave.Error when a file violates
the WAV format, but it leaks a raw EOFError when the fmt chunk is truncated
(the chunk header declares 16 bytes but fewer are present):

>>> import io, struct, wave
>>> b = b'RIFF' + struct.pack('<L', 24) + b'WAVE' + b'fmt ' + struct.pack('<L', 16) + struct.pack('<HHLLH', 1, 1, 11025, 11025, 1)
>>> wave.open(io.BytesIO(b))
Traceback (most recent call last):
  ...
EOFError

Expected: wave.Error. Wave_read._read_fmt_chunk() raises EOFError on a
short read, but Wave_read.initfp() does not wrap that call, so it escapes the
public API. Every other malformed-input path in the module raises wave.Error.

CPython versions tested on

3.13, 3.14, 3.15

Operating systems tested on

Linux, macOS

Linked PRs
  • gh-153693

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da wave.open e ispeziona Wave_read.initfp() e Wave_read._read_fmt_chunk(), che il report identifica come i punti di ingresso rilevanti. Aggiungi un controllo di regressione per un chunk fmt troncato e verifica che un input malformato sollevi wave.Error invece di EOFError; gh-153693 è già collegato a questo lavoro.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
audio-video-rtc
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.