Test files › Audio and video › truncated-header.wav
WAV file with a truncated header
A WAV file cut off after 30 bytes, mid-header.
↓ Download truncated-header.wav| Filename | truncated-header.wav |
| Format | WAV |
| Size | 30 bytes (30 bytes) |
| MIME type | audio/wav |
| SHA-256 | 1a34ac609c1addcfc3c4e0980b57659d1bbc93a942afe4b39d671e3b1d9aa054 |
What this file catchesParsers that read fixed offsets without bounds-checking and throw an out-of-range error instead of reporting a malformed file.
Handle it in code
Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.
Python
Compare what the header declares with what the file holds, and refuse a header that is itself cut short.
import wave
try:
with wave.open("truncated-header.wav") as w:
declared = w.getnframes()
frame_size = w.getsampwidth() * w.getnchannels()
actual = len(w.readframes(declared)) // frame_size
note = "truncated or lying header" if actual < declared else "ok"
print(f"header says {declared} frames, file holds {actual}: {note}")
except (wave.Error, EOFError) as e:
print("rejected:", str(e) or "the header is cut short")Run against this file, it prints: rejected: the header is cut short
Related guides and tools
Download & verify
curl -fsSL -o "truncated-header.wav" "https://files.hexaqa.com/audio/truncated-header.wav"
curl -fsSL "https://files.hexaqa.com/audio/truncated-header.wav" | sha256sum
# expect: 1a34ac609c1addcfc3c4e0980b57659d1bbc93a942afe4b39d671e3b1d9aa054