diff options
author | 2020-10-12 13:56:22 +0000 | |
---|---|---|
committer | 2020-10-12 13:56:22 +0000 | |
commit | 4ff7982ab36499c1dd8a66a8edc78e0c252e81d4 (patch) | |
tree | aa17ef61aa8580b27f1f3cc2d73272b90df4eb81 | |
parent | avoid two overlong lines and drop an unused printf argument (diff) | |
download | wireguard-openbsd-4ff7982ab36499c1dd8a66a8edc78e0c252e81d4.tar.xz wireguard-openbsd-4ff7982ab36499c1dd8a66a8edc78e0c252e81d4.zip |
Accommodate POSIX basename(3) that takes a non-const parameter and
may modify the string buffer. ok millert@
-rw-r--r-- | usr.bin/compress/main.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index c7b2cc8efda..b7210174135 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.96 2019/06/28 13:35:00 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.97 2020/10/12 13:56:22 naddy Exp $ */ /* * Copyright (c) 1992, 1993 @@ -481,6 +481,7 @@ docompress(const char *in, char *out, const struct compressor *method, { #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, const struct compressor *method, } 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) { |