Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Sep 2005 23:30:17 GMT
From:      Giorgos Keramidas <keramida@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/85712: uncompress(1) program emits bogus "overwrite?" prompt
Message-ID:  <200509062330.j86NUHTO082013@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/85712; it has been noted by GNATS.

From: Giorgos Keramidas <keramida@freebsd.org>
To: "Gary W. Swearingen" <garys@freebsd.org>
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" <garys@freebsd.org> 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.
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509062330.j86NUHTO082013>