diff options
author | 2008-10-08 17:06:30 +0000 | |
---|---|---|
committer | 2008-10-08 17:06:30 +0000 | |
commit | 99a71572549ca363e03d0cdddf75fe3694dba9ad (patch) | |
tree | b420481150f8915e867c0545e976fd2a289d5524 | |
parent | Fix the order of traversal when printing the queues. Properly places (diff) | |
download | wireguard-openbsd-99a71572549ca363e03d0cdddf75fe3694dba9ad.tar.xz wireguard-openbsd-99a71572549ca363e03d0cdddf75fe3694dba9ad.zip |
For "gunzip -N", the name stored in the gzip header has no directory,
so write the uncompressed file in the same directory we would use
were the -N option not specified. Closes PR 5224
-rw-r--r-- | usr.bin/compress/main.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index ed3f8a07314..d480275b1dc 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.73 2008/07/27 13:15:31 sobrado Exp $ */ +/* $OpenBSD: main.c,v 1.74 2008/10/08 17:06:30 millert Exp $ */ #ifndef SMALL static const char copyright[] = @@ -36,7 +36,7 @@ static const char license[] = #endif /* SMALL */ #ifndef SMALL -static const char main_rcsid[] = "$OpenBSD: main.c,v 1.73 2008/07/27 13:15:31 sobrado Exp $"; +static const char main_rcsid[] = "$OpenBSD: main.c,v 1.74 2008/10/08 17:06:30 millert Exp $"; #endif #include <sys/param.h> @@ -633,7 +633,12 @@ dodecompress(const char *in, char *out, const struct compressor *method, return (FAILURE); } if (storename && oldname[0] != '\0') { - strlcpy(out, oldname, MAXPATHLEN); + char *cp = strrchr(out, '/'); + if (cp != NULL) { + *(cp + 1) = '\0'; + strlcat(out, oldname, MAXPATHLEN); + } else + strlcpy(out, oldname, MAXPATHLEN); cat = 0; /* XXX should -c override? */ } |