From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 6 23:30:17 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E12B716A41F for ; Tue, 6 Sep 2005 23:30:17 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4822B43D48 for ; Tue, 6 Sep 2005 23:30:17 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j86NUH4d082014 for ; Tue, 6 Sep 2005 23:30:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j86NUHTO082013; Tue, 6 Sep 2005 23:30:17 GMT (envelope-from gnats) Date: Tue, 6 Sep 2005 23:30:17 GMT Message-Id: <200509062330.j86NUHTO082013@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Cc: Subject: Re: bin/85712: uncompress(1) program emits bogus "overwrite?" prompt X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Sep 2005 23:30:18 -0000 The following reply was made to PR bin/85712; it has been noted by GNATS. From: Giorgos Keramidas To: "Gary W. Swearingen" Cc: bug-followup@freebsd.org Subject: Re: bin/85712: uncompress(1) program emits bogus "overwrite?" prompt Date: Wed, 7 Sep 2005 02:20:19 +0300 On 2005-09-04 09:47, "Gary W. Swearingen" wrote: > The uncompress(1) program, when given a filename without a .Z > extension, prompts the user for confirmation and if given "y", it then > ignores the reply and then complains about the missing .Z extension. I can confirm this bug exists in CURRENT too. > This PR should be suspended immediately for the "lack of resources" > reason, because it is an unimportant bug that only wastes a little > users' time. Unless we get it fixed by committing the following: %%% Index: compress.c =================================================================== RCS file: /home/ncvs/src/usr.bin/compress/compress.c,v retrieving revision 1.21 diff -u -r1.21 compress.c --- compress.c 14 Jun 2003 13:41:31 -0000 1.21 +++ compress.c 6 Sep 2005 23:04:44 -0000 @@ -204,7 +204,7 @@ int exists, isreg, oreg; u_char buf[1024]; - exists = !stat(out, &sb); + exists = (stat(in, &sb) == 0 && stat(out, &sb) == 0); if (!force && exists && S_ISREG(sb.st_mode) && !permission(out)) return; isreg = oreg = !exists || S_ISREG(sb.st_mode); @@ -294,7 +294,7 @@ int exists, isreg, oreg; u_char buf[1024]; - exists = !stat(out, &sb); + exists = (stat(in, &sb) == 0 && stat(out, &sb) == 0); if (!force && exists && S_ISREG(sb.st_mode) && !permission(out)) return; isreg = oreg = !exists || S_ISREG(sb.st_mode); %%% With this patch, the behavior of both compress and uncompress makes more sense, since they warn about missing input files *before* the permission() function checks for overwrite access. IMHO, it's ok to use stat() on both the input and output file here, since the checks for success and/or failure later on protect against files going away under compress(1) or uncompress(1) between the time the stat() and permission() calls run and the time the files are really opened.