Accommodate POSIX basename(3) that takes a non-const parameter and may in fact modify the string buffer.
Following martijn@'s comment for the sed diff, we don't need to check for truncation because the "in" path has already been validated by a preceding open(2). ok? Index: usr.bin/compress/main.c =================================================================== RCS file: /cvs/src/usr.bin/compress/main.c,v retrieving revision 1.96 diff -u -p -r1.96 main.c --- usr.bin/compress/main.c 28 Jun 2019 13:35:00 -0000 1.96 +++ usr.bin/compress/main.c 10 Oct 2020 20:10:44 -0000 @@ -481,6 +481,7 @@ docompress(const char *in, char *out, co { #ifndef SMALL u_char buf[Z_BUFSIZE]; + char namebuf[PATH_MAX]; char *name; int error, ifd, ofd, oreg; void *cookie; @@ -534,7 +535,8 @@ docompress(const char *in, char *out, co } if (!pipin && storename) { - name = basename(in); + strlcpy(namebuf, in, sizeof(namebuf)); + name = basename(namebuf); mtime = (u_int32_t)sb->st_mtime; } if ((cookie = method->wopen(ofd, name, bits, mtime)) == NULL) { -- Christian "naddy" Weisgerber na...@mips.inka.de