summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree/spec.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-10-30 12:03:25 +0000
committerphk <phk@FreeBSD.org>2003-10-30 12:03:25 +0000
commit10c0052ec4ac1d18a7c1d6025ce3f9ffb1440cb6 (patch)
tree5630471086317d8b7d185333d255ae3980608d94 /usr.sbin/mtree/spec.c
parent3b266c3cbf9a561d5b610513656365deed12d8d4 (diff)
downloadFreeBSD-src-10c0052ec4ac1d18a7c1d6025ce3f9ffb1440cb6.zip
FreeBSD-src-10c0052ec4ac1d18a7c1d6025ce3f9ffb1440cb6.tar.gz
Use vis(3) to encode/decode the target for symlinks.
Make vis(3) decode errors fatal for both symlink targets and fienames.
Diffstat (limited to 'usr.sbin/mtree/spec.c')
-rw-r--r--usr.sbin/mtree/spec.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c
index 230847d..71038da 100644
--- a/usr.sbin/mtree/spec.c
+++ b/usr.sbin/mtree/spec.c
@@ -143,11 +143,8 @@ noparent: errx(1, "line %d: no parent node", lineno);
#define MAGIC "?*["
if (strpbrk(p, MAGIC))
centry->flags |= F_MAGIC;
- if (strunvis(centry->name, p) == -1) {
- warnx("filename %s is ill-encoded and literally used",
- p);
- strcpy(centry->name, p);
- }
+ if (strunvis(centry->name, p) == -1)
+ errx(1, "filename %s is ill-encoded", p);
set(NULL, centry);
if (!root) {
@@ -244,8 +241,11 @@ set(char *t, NODE *ip)
lineno, val);
break;
case F_SLINK:
- if ((ip->slink = strdup(val)) == NULL)
- errx(1, "strdup");
+ ip->slink = malloc(strlen(val));
+ if (ip->slink == NULL)
+ errx(1, "malloc");
+ if (strunvis(ip->slink, val) == -1)
+ errx(1, "symlink %s is ill-encoded", val);
break;
case F_TIME:
ip->st_mtimespec.tv_sec = strtoul(val, &ep, 10);
OpenPOWER on IntegriCloud