From: dv Date: Fri, 28 Apr 2023 21:22:20 +0000 (+0000) Subject: vmd(8): fix specifying boot image in vm.conf X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3ac1122da640464f1b51ce01b3cd714e2ecb68e5;p=openbsd vmd(8): fix specifying boot image in vm.conf Previous change to allow overriding changed the way we parsed and stored the boot image path. The lifetime of the path was...much too short. Heap allocate the kernel path. Found by Mischa Peters. ok mlarkin@ --- diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y index ea91e745ac6..09468e3fe2c 100644 --- a/usr.sbin/vmd/parse.y +++ b/usr.sbin/vmd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.66 2023/04/28 19:46:42 dv Exp $ */ +/* $OpenBSD: parse.y,v 1.67 2023/04/28 21:22:20 dv Exp $ */ /* * Copyright (c) 2007-2016 Reyk Floeter @@ -477,7 +477,10 @@ vm_opts : disable { YYERROR; } free($2); - kernel = path; + kernel = malloc(sizeof(path)); + if (kernel == NULL) + yyerror("malloc"); + memcpy(kernel, &path, sizeof(path)); vmc.vmc_flags |= VMOP_CREATE_KERNEL; } | BOOT DEVICE bootdevice {