Date: Sat, 16 Mar 2002 15:50:03 -0800 (PST) From: "Andrew L. Neporada" <andr@dgap.mipt.ru> To: freebsd-bugs@FreeBSD.org Subject: [PATCH] Re: bin/35226 mtree strange behaviour on some filenames Message-ID: <200203162350.g2GNo3A92268@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/35226; it has been noted by GNATS.
From: "Andrew L. Neporada" <andr@dgap.mipt.ru>
To: bug-followup@freebsd.org
Cc: oyvind@punkass.com
Subject: [PATCH] Re: bin/35226 mtree strange behaviour on some filenames
Date: Sun, 17 Mar 2002 02:46:32 +0300 (MSK)
Bug happens when the first symbol of filename is '#', because '#'
is the comment marker also.
Apply following patch (patch done against -current):
Index: create.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mtree/create.c,v
retrieving revision 1.22
diff -u -r1.22 create.c
--- create.c 5 Jul 2001 07:52:56 -0000 1.22
+++ create.c 16 Mar 2002 21:59:58 -0000
@@ -159,7 +159,12 @@
escaped_name = calloc(1, p->fts_namelen * 4 + 1);
if (escaped_name == NULL)
errx(1, "statf(): calloc() failed");
- strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL);
+ len = strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL);
+ if (escaped_name[0] == '#') {
+ for (val = len; val; val--)
+ escaped_name[val] = escaped_name[val-1];
+ escaped_name[0] = '\\';
+ }
if (iflag || S_ISDIR(p->fts_statp->st_mode))
offset = printf("%*s%s", indent, "", escaped_name);
Index: spec.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mtree/spec.c,v
retrieving revision 1.14
diff -u -r1.14 spec.c
--- spec.c 17 Jun 2000 14:19:33 -0000 1.14
+++ spec.c 16 Mar 2002 22:24:52 -0000
@@ -65,6 +65,7 @@
register char *p;
NODE ginfo, *root;
int c_cur, c_next;
+ u_long i, len;
char buf[2048];
centry = last = root = NULL;
@@ -147,6 +148,11 @@
#define MAGIC "?*["
if (strpbrk(p, MAGIC))
centry->flags |= F_MAGIC;
+ if (p[0] == '\\' && p[1] == '#') {
+ len = strlen(p);
+ for(i = 0; i < len; i++)
+ p[i] = p[i + 1];
+ }
if (strunvis(centry->name, p) == -1) {
warnx("filename %s is ill-encoded and literally used",
p);
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203162350.g2GNo3A92268>
