diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2020-10-15 19:42:57 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2020-10-15 19:42:57 +0000 |
commit | 79c3cab0594e55b9ebaed093a5142fae23892171 (patch) | |
tree | 157b6fe87265cd8efab416531729fd2b8cbaf8d4 /bin | |
parent | 021714eb4b7ec9dd39289addb1389fdbdb5da4d4 (diff) |
Explicitly skip a leading "/dev/" and do not rely on basename(3) and
non-POSIX basename semantics.
ok millert@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/chio/parse.y | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/chio/parse.y b/bin/chio/parse.y index e735569bce9..9e0d2ae2ab9 100644 --- a/bin/chio/parse.y +++ b/bin/chio/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.22 2019/02/13 22:57:07 deraadt Exp $ */ +/* $OpenBSD: parse.y,v 1.23 2020/10/15 19:42:56 naddy Exp $ */ /* * Copyright (c) 2006 Bob Beck <beck@openbsd.org> @@ -29,6 +29,7 @@ #include <err.h> #include <libgen.h> #include <limits.h> +#include <paths.h> #include <stdarg.h> #include <stdio.h> #include <string.h> @@ -445,10 +446,12 @@ parse_tapedev(const char *filename, const char *changer, int drive) errors = file->errors; popfile(); + if (strncmp(changer, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) + changer += sizeof(_PATH_DEV) - 1; TAILQ_FOREACH(p, &changers, entry) { - if (strcmp(basename(changer), p->name) == 0) { + if (strcmp(changer, p->name) == 0) { if (drive >= 0 && drive < p->drivecnt) { - if (asprintf(&tapedev, "/dev/%s", + if (asprintf(&tapedev, _PATH_DEV "%s", p->drives[drive]) == -1) errx(1, "malloc failed"); } else |