summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree/create.c
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>1999-01-12 02:58:23 +0000
committerjkoshy <jkoshy@FreeBSD.org>1999-01-12 02:58:23 +0000
commitc93a7d05cf03dd9930b14d50f3efc2b7693d6a0c (patch)
tree1093b5c1136631fc06015ad6b77db87832152c8d /usr.sbin/mtree/create.c
parentcdf79e6bf32b91067c032e57abfe26ce17dc7089 (diff)
downloadFreeBSD-src-c93a7d05cf03dd9930b14d50f3efc2b7693d6a0c.zip
FreeBSD-src-c93a7d05cf03dd9930b14d50f3efc2b7693d6a0c.tar.gz
Teach mtree(8) to handle whitespace in filenames. Uses strvis(3).
PR: bin/3246 Submitted by: Eugene M. Kim <astralblue@usa.net> Reviewed by: jkoshy, wollman
Diffstat (limited to 'usr.sbin/mtree/create.c')
-rw-r--r--usr.sbin/mtree/create.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c
index af9f504..e5fbe20 100644
--- a/usr.sbin/mtree/create.c
+++ b/usr.sbin/mtree/create.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: create.c,v 1.10 1998/06/05 14:43:39 peter Exp $";
+ "$Id: create.c,v 1.11 1998/08/02 14:41:34 bde Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -52,6 +52,7 @@ static const char rcsid[] =
#include <stdio.h>
#include <time.h>
#include <unistd.h>
+#include <vis.h>
#include "mtree.h"
#include "extern.h"
@@ -138,11 +139,19 @@ statf(indent, p)
struct passwd *pw;
u_long len, val;
int fd, offset;
+ char *escaped_name;
+
+ 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);
if (iflag || S_ISDIR(p->fts_statp->st_mode))
- offset = printf("%*s%s", indent, "", p->fts_name);
+ offset = printf("%*s%s", indent, "", escaped_name);
else
- offset = printf("%*s %s", indent, "", p->fts_name);
+ offset = printf("%*s %s", indent, "", escaped_name);
+
+ free(escaped_name);
if (offset > (INDENTNAMELEN + indent))
offset = MAXLINELEN;
OpenPOWER on IntegriCloud