#1140782 reportbug: zstd 1.5.4 crashes when trying to compress to a not writable file

Package:
zstd
Source:
zstd
Description:
fast lossless compression algorithm -- CLI tool
Submitter:
Alex Laskin
Date:
2026-06-26 11:05:02 UTC
Severity:
normal
Tags:
#1140782#5
Date:
2026-06-26 10:55:00 UTC
From:
To:
Dear Maintainer,

Current stable zstd version segfaults when trying to use output file
without permissions or with other problems.

Expected output:
# echo test | zstd -fo /sys/not_writable_file ; echo $?
zstd: /sys/not_writable_file: Read-only file system
1

Actual output:
# echo test | zstd -fo /sys/not_writable_file ; echo $?
zstd: /sys/not_writable_file: Read-only file system
Caught SIGSEGV signal, printing stack:
/lib/x86_64-linux-gnu/libc.so.6(setvbuf+0x11) [0x72177a336fa1]
zstd(+0xeb977) [0x5f2f83add977]
zstd(+0xf14fe) [0x5f2f83ae34fe]
zstd(+0xf579f) [0x5f2f83ae779f]
zstd(+0x61b0) [0x5f2f839f81b0]
/lib/x86_64-linux-gnu/libc.so.6(+0x2724a) [0x72177a2e624a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x72177a2e6305]
zstd(+0x7f81) [0x5f2f839f9f81]
Segmentation fault (core dumped)
139

Upstream issue was fixed at https://github.com/facebook/zstd/pull/3541
I have verified that this issue does not reproduce with newer Debian zstd versions (1.5.7 in trixie).
I am still reporting it because the crash is present in the current bookworm.