diff options
-rw-r--r-- | usr.sbin/mtree/create.c | 17 | ||||
-rw-r--r-- | usr.sbin/mtree/spec.c | 11 |
2 files changed, 20 insertions, 8 deletions
diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index 65ae8060094..9ee864a6395 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -1,5 +1,5 @@ /* $NetBSD: create.c,v 1.11 1996/09/05 09:24:19 mycroft Exp $ */ -/* $OpenBSD: create.c,v 1.17 2002/03/14 16:44:25 mpech Exp $ */ +/* $OpenBSD: create.c,v 1.18 2002/03/14 17:01:16 millert Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93"; #else -static const char rcsid[] = "$OpenBSD: create.c,v 1.17 2002/03/14 16:44:25 mpech Exp $"; +static const char rcsid[] = "$OpenBSD: create.c,v 1.18 2002/03/14 17:01:16 millert Exp $"; #endif #endif /* not lint */ @@ -145,7 +145,7 @@ statf(indent, p) struct passwd *pw; u_int32_t len, val; int fd, offset; - char *escaped_name; + char *name, *escaped_name; escaped_name = malloc(p->fts_namelen * 4 + 1); if (escaped_name == NULL) @@ -235,8 +235,15 @@ statf(indent, p) output(indent, &offset, "sha1digest=%s", sha1digest); } if (keys & F_SLINK && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) - output(indent, &offset, "link=%s", rlink(p->fts_accpath)); + (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { + name = rlink(p->fts_accpath); + escaped_name = malloc(strlen(name) * 4 + 1); + if (escaped_name == NULL) + error("statf: %s", strerror(errno)); + strvis(escaped_name, name, VIS_WHITE | VIS_OCTAL); + output(indent, &offset, "link=%s", escaped_name); + free(escaped_name); + } if (keys & F_FLAGS && !S_ISLNK(p->fts_statp->st_mode)) { char *file_flags; diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c index 8f65aed927d..6499e9046de 100644 --- a/usr.sbin/mtree/spec.c +++ b/usr.sbin/mtree/spec.c @@ -1,5 +1,5 @@ /* $NetBSD: spec.c,v 1.6 1995/03/07 21:12:12 cgd Exp $ */ -/* $OpenBSD: spec.c,v 1.15 2002/03/14 16:44:25 mpech Exp $ */ +/* $OpenBSD: spec.c,v 1.16 2002/03/14 17:01:16 millert Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 6/6/93"; #else -static const char rcsid[] = "$OpenBSD: spec.c,v 1.15 2002/03/14 16:44:25 mpech Exp $"; +static const char rcsid[] = "$OpenBSD: spec.c,v 1.16 2002/03/14 17:01:16 millert Exp $"; #endif #endif /* not lint */ @@ -248,8 +248,13 @@ set(t, ip) error("invalid size %s", val); break; case F_SLINK: - if ((ip->slink = strdup(val)) == NULL) + if ((ip->slink = malloc(strlen(val) + 1)) == NULL) error("%s", strerror(errno)); + if (strunvis(ip->slink, val) == -1) { + fprintf(stderr, + "mtree: filename (%s) encoded incorrectly\n", val); + strcpy(ip->slink, val); + } break; case F_TIME: ip->st_mtimespec.tv_sec = strtoul(val, &ep, 10); |