Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jul 2007 08:51:42 GMT
From:      Ighighi <ighighi@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/114470: [patch]: gzip(1): bad recursive behaviour 
Message-ID:  <200707100851.l6A8pgXq077762@www.freebsd.org>
Resent-Message-ID: <200707100900.l6A90BBi060136@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         114470
>Category:       bin
>Synopsis:       [patch]: gzip(1): bad recursive behaviour
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 10 09:00:10 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Ighighi
>Release:        6.2-STABLE
>Organization:
>Environment:
FreeBSD orion 6.2-STABLE FreeBSD 6.2-STABLE #3: Mon Jul  9 23:03:53 VET 2007     root@orion:/usr/obj/usr/src/sys/CUSTOM  i386

>Description:
The handle_dir() function should pass fts_path and not fts_name because the latter
is the basename(3).  Because of this, not just verbose output but error messages
as well are ambiguous when files with the same name exist...
It's also an issue when compatibility with GNU gzip(1) is desired.
>How-To-Repeat:
$ /bin/mkdir /tmp/x /tmp/y
$ /bin/cp /etc/services /tmp/x
$ /bin/cp /etc/services /tmp/y
$ /bin/chmod 000 /tmp/x/services
$ /usr/bin/gzip -vr /tmp/x /tmp/y
gzip: can't open services: Permission denied
services:          71.7% -- replaced with services.gz
$ /usr/bin/gzip --version
FreeBSD gzip 20070528

### Now with GNU gzip(1) in ports:

$ /bin/mkdir /tmp/x /tmp/y
$ /bin/cp /etc/services /tmp/x
$ /bin/cp /etc/services /tmp/y
$ /bin/chmod 000 /tmp/x/services
$ /usr/local/bin/gzip -vr /tmp/x /tmp/y
gzip: /tmp/x/services: Permission denied
/tmp/y/services:         71.8% -- replaced with /tmp/y/services.gz
$ /usr/local/bin/gzip --version
gzip 1.3.12
Copyright (C) 2007 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Jean-loup Gailly.

>Fix:
Attached patch successfully built and tested on FreeBSD 6.2-STABLE and
known to patch in -CURRENT.

To apply, run:
patch -d /usr < /path/to/patch
cd /usr/src/usr.bin/gzip
make clean obj depend && make && make install

Patch attached with submission follows:

--- src/usr.bin/gzip/gzip.c.orig	Sat Jun 30 06:13:00 2007
+++ src/usr.bin/gzip/gzip.c	Tue Jul 10 04:08:11 2007
@@ -1806,7 +1806,7 @@
 
 	path_argv[0] = dir;
 	path_argv[1] = 0;
-	fts = fts_open(path_argv, FTS_PHYSICAL, NULL);
+	fts = fts_open(path_argv, FTS_PHYSICAL | FTS_NOCHDIR, NULL);
 	if (fts == NULL) {
 		warn("couldn't fts_open %s", dir);
 		return;
@@ -1824,7 +1824,7 @@
 			maybe_warn("%s", entry->fts_path);
 			continue;
 		case FTS_F:
-			handle_file(entry->fts_name, entry->fts_statp);
+			handle_file(entry->fts_path, entry->fts_statp);
 		}
 	}
 	(void)fts_close(fts);


>Release-Note:
>Audit-Trail:
>Unformatted:



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