On 2025-04-08 11:43, Nelson H. F. Beebe wrote:
Here is the requested test on DragonFlyBSD for gzip-1.13.56-e549:

% cat foo.sh
#! /bin/sh
mkdir d
echo >d/f
chmod a-w d
./gzip d/f

% ./foo.sh
gzip: d/f.gz already exists; do you wish to overwrite (y or n)? y
gzip: d/f.gz: No such file or directory

I then applied the one-line patch to tests/write-error:

%  diff ./write-error.org ./write-error
27c27,28
< if test -w d || test `id -u` = 0; then
---
# if test -w d || test `id -u` = 0; then
if echo > d/e; then

% cd ..
% make check
... PASS reports ...
PASS: unpack-invalid
PASS: unpack-valid
PASS: upper-suffix
[hangs at this point]

If I run the script in the tests directory, I get

%  ./write-error
./write-error: cannot create d/e: Permission denied
[again at this point]

Thanks for the further checking on DragonFlyBSD. My guess about the syscall bug was incorrect, unfortunately.

I suspect that openat with O_WRONLY|O_CREAT|O_EXCL isn't working correctly if the directory fd points to an unwriteable directory opened via O_SEARCH|O_DIRECTORY, and that openat misbehaves by failing with errno==EEXIST. If my guess is right, I don't see an easy way for gzip to work around the kernel bug.



Reply via email to