summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/parse.y
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2018-10-18 08:36:12 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2018-10-18 08:36:12 +0000
commit611af7a234b0ec53823b39c3af69f84e7382fc16 (patch)
tree7eba3ee5a915f0f52f2ddfa07da9aeeb7dd3a7a9 /usr.sbin/vmd/parse.y
parentb1bc2041af472e985c362fd63bbe3bb34a474802 (diff)
Use realpath(3) on the "boot" config option as well.
This fixes code that detects if boot and the first disk are identical. OK mlarkin@
Diffstat (limited to 'usr.sbin/vmd/parse.y')
-rw-r--r--usr.sbin/vmd/parse.y14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y
index 545c7679049..5afa28b8f08 100644
--- a/usr.sbin/vmd/parse.y
+++ b/usr.sbin/vmd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.45 2018/10/01 09:31:15 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.46 2018/10/18 08:36:11 reyk Exp $ */
/*
* Copyright (c) 2007-2016 Reyk Floeter <reyk@openbsd.org>
@@ -416,20 +416,26 @@ vm_opts : disable {
vmc.vmc_flags |= VMOP_CREATE_NETWORK;
}
| BOOT string {
+ char path[PATH_MAX];
+
if (vcp->vcp_kernel[0] != '\0') {
yyerror("kernel specified more than once");
free($2);
YYERROR;
}
- if (strlcpy(vcp->vcp_kernel, $2,
+ if (realpath($2, path) == NULL) {
+ yyerror("kernel path not found");
+ free($2);
+ YYERROR;
+ }
+ free($2);
+ if (strlcpy(vcp->vcp_kernel, path,
sizeof(vcp->vcp_kernel)) >=
sizeof(vcp->vcp_kernel)) {
yyerror("kernel name too long");
- free($2);
YYERROR;
}
- free($2);
vmc.vmc_flags |= VMOP_CREATE_KERNEL;
}
| CDROM string {