From owner-freebsd-doc Sun Jan 5 20: 3:29 2003 Delivered-To: freebsd-doc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 14BF137B401 for ; Sun, 5 Jan 2003 20:03:28 -0800 (PST) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id F25F943ED1 for ; Sun, 5 Jan 2003 20:03:26 -0800 (PST) (envelope-from keramida@freebsd.org) Received: from gothmog.gr (patr530-a104.otenet.gr [212.205.215.104]) by mailsrv.otenet.gr (8.12.6/8.12.6) with ESMTP id h0643D4V025250; Mon, 6 Jan 2003 06:03:14 +0200 (EET) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.6/8.12.6) with ESMTP id h0643DsX006657; Mon, 6 Jan 2003 06:03:13 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.12.6/8.12.6/Submit) id h0643DQS006656; Mon, 6 Jan 2003 06:03:13 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Mon, 6 Jan 2003 06:03:12 +0200 From: Giorgos Keramidas To: "Gary W. Swearingen" Cc: doc@freebsd.org Subject: Re: docs/46787: compress(1) manpage missing BUGS; other cleanup. Message-ID: <20030106040312.GA6593@gothmog.gr> References: <20030105225020.GA2565@gothmog.gr> <5zy95zknwe.95z@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5zy95zknwe.95z@localhost.localdomain> Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On 2003-01-05 18:33, "Gary W. Swearingen" wrote: > For easiest example is to copy a plain text file to "xxx" and do > "ls xxx*; uncompress -f xxx"; ls xxx*. Gone. Try it again and also > copy a different size file to "xxx.Z". Gone. Try it once more but > ensure that "xxx.Z" is a real compressed file. Not gone, just > overwritten, as the manpage has always said. > > Thanks for your comments. Well, thank you to for reporting this! I think I have located the source of this bug. I just added the following comment to a local tree, and I'm off to bed since it's way past my bedtime. Tomorrow, I will try to fix this and ask the friendly reviewers of freebsd-audit to bitch at me until the bug is fixed in a way that makes everyone happy :=) %%% Index: compress.c =================================================================== RCS file: /home/ncvs/src/usr.bin/compress/compress.c,v retrieving revision 1.20 diff -u -r1.20 compress.c --- compress.c 28 Jul 2002 15:32:17 -0000 1.20 +++ compress.c 6 Jan 2003 03:56:32 -0000 @@ -170,6 +170,19 @@ len = strlen(*argv); if ((p = rindex(*argv, '.')) == NULL || strcmp(p, ".Z")) { + /* + * XXX: We are running in "decompress" mode & + * filename does not end in ".Z". Try to + * stick a .Z extension to it, and attempt to + * decompress that file instead. This can + * cause existing files to be overwritten if + * `*argv' happens to be a real file, so we + * should check with stat() here to see if the + * file `*argv' exists already, and avoid + * overwriting it in decompress() if and only + * if `*argv' exists AND `newname' does NOT + * exist at the same time. + */ if (len > sizeof(newname) - 3) { cwarnx("%s: name too long", *argv); break; %%% To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message