From 663bf3c0c7e9590c183ed00c68964d28cadad8a7 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 26 Apr 2019 10:46:11 -0700 Subject: gzip: fix regressions caused by 7964e1f78b58d9c365361cc36b0422d9d56cd204. The permissions preservation test still fails for me, but that seems to be because my environment changed: it's failing because of my umask. I'll fix that in a separate patch, since it's unrelated. --- toys/lsb/gzip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toys/lsb/gzip.c b/toys/lsb/gzip.c index 82e76698..df5bf3af 100644 --- a/toys/lsb/gzip.c +++ b/toys/lsb/gzip.c @@ -130,7 +130,7 @@ static void do_gzip(int ifd, char *in) // Add or remove .gz suffix as necessary if (!FLAG(d)) out = xmprintf("%s%s", in, ".gz"); - else if ((out = strend(out, ".gz"))>in) out = xstrndup(out, out-in); + else if ((out = strend(in, ".gz"))>in) out = xstrndup(in, out-in); else return error_msg("no .gz: %s", in); ofd = xcreate(out, O_CREAT|O_WRONLY|WARN_ONLY|(O_EXCL*!FLAG(f)),sb.st_mode); @@ -142,7 +142,7 @@ static void do_gzip(int ifd, char *in) if (out) { struct timespec times[] = {sb.st_atim, sb.st_mtim}; - if (futimens(ofd, times)) perror_exit("utimensat"); + if (utimensat(AT_FDCWD, out, times, 0)) perror_exit("utimensat"); close(ofd); if (!FLAG(k) && in && unlink(in)) perror_msg("unlink %s", in); free(out); -- cgit v1.2.3