Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Nov 2007 17:48:38 +0100 (CET)
From:      Ulrich Spörlein <uspoerlein@gmail.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/118132: [PATCH] pax(1): broken -s handling of \1, \2 ...
Message-ID:  <200711191648.lAJGmcrD037968@coyote.spoerlein.net>
Resent-Message-ID: <200711191720.lAJHK2OD059656@freefall.freebsd.org>

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

>Number:         118132
>Category:       bin
>Synopsis:       [PATCH] pax(1): broken -s handling of \1, \2 ...
>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:   Mon Nov 19 17:20:02 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Ulrich Spörlein
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
1822direkt.com
>Environment:
>Description:
I was using pax(1) on RHEL 4 to be able to transform filenames upon extraction, this breaks
under FreeBSD (and at least Ubuntu 7.04, too)
>How-To-Repeat:
% mkdir foo
% touch foo/bar_baz
% echo foo/bar_baz|pax -rw -s ',^[^/]*/\(.*\)_baz$,\1,gp' /tmp
pax: Replacement name error foo/bar_baz
>Fix:
I stole the patch from the Debian bugtracker:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451361

After recompile:
% echo foo/bar_baz | /usr/obj/usr/src/bin/pax/pax -rw -s ',^[^/]*/\(.*\)_baz$,\1,gp' /tmp
foo/bar_baz >> bar

This should be reported upstream, but I couldn't find a definitive source for our pax(1).
Someone should test this on other *BSDs, too.

--- pax.diff begins here ---
--- bin/pax/pat_rep.c.orig	Mon Nov 19 17:37:11 2007
+++ bin/pax/pat_rep.c	Mon Nov 19 17:38:39 2007
@@ -76,7 +76,7 @@
 #ifdef NET2_REGEX
 static int resub(regexp *, char *, char *, char *);
 #else
-static int resub(regex_t *, regmatch_t *, char *, char *, char *);
+static int resub(regex_t *, regmatch_t *, char *, char *, char *, char *);
 #endif
 
 /*
@@ -929,7 +929,7 @@
 #			ifdef NET2_REGEX
 			if ((res = resub(pt->rcmp,pt->nstr,outpt,endpt)) < 0) {
 #			else
-			if ((res = resub(&(pt->rcmp),pm,pt->nstr,outpt,endpt))
+			if ((res = resub(&(pt->rcmp),pm,inpt,pt->nstr,outpt,endpt))
 			    < 0) {
 #			endif
 				if (prnt)
@@ -1071,7 +1071,7 @@
  */
 
 static int
-resub(regex_t *rp, regmatch_t *pm, char *src, char *dest,
+resub(regex_t *rp, regmatch_t *pm, char *orig, char *src, char *dest,
 	char *destend)
 {
 	char *spt;
@@ -1121,7 +1121,7 @@
 		 */
 		if (len > (destend - dpt))
 			len = destend - dpt;
-		if (l_strncpy(dpt, src + pmpt->rm_so, len) != len)
+		if (l_strncpy(dpt, orig + pmpt->rm_so, len) != len)
 			return(-1);
 		dpt += len;
 	}
--- pax.diff ends here ---


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



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