[zstdcli] Refuse to overwrite input file
Compare the input and output files by their inode number and refuse to open the output file if the input file is the same. This doesn't work when (de)compressing multiple files to a single file, but that is a very uncommon use case, mostly used for benchmarking by me. Fixes #1422.
This commit is contained in:
@@ -183,6 +183,9 @@ $ECHO "test: --no-progress flag"
|
||||
$ZSTD tmpro -c --no-progress | $ZSTD -d -o "$INTOVOID" --no-progress
|
||||
$ZSTD tmpro -cv --no-progress | $ZSTD -dv -o "$INTOVOID" --no-progress
|
||||
rm -f tmpro tmpro.zst
|
||||
$ECHO "test: overwrite input file (must fail)"
|
||||
$ZSTD tmp -fo tmp && die "zstd overwrote the input file"
|
||||
$ZSTD tmp.zst -dfo tmp.zst && die "zstd overwrote the input file"
|
||||
|
||||
|
||||
$ECHO "test : file removal"
|
||||
|
||||
Reference in New Issue
Block a user