From: mlarkin Date: Mon, 29 May 2017 07:15:22 +0000 (+0000) Subject: vmd(8): prevent crashing when presented with a vm name argument to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fdd666a71eca7c68909e7caa2ec9b8126985b3ad;p=openbsd vmd(8): prevent crashing when presented with a vm name argument to "vmctl stop" that doesn't exist. Diff from Pratik Vyas, thanks! --- diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 013bf26be8a..440d64f87de 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.61 2017/05/04 19:41:58 reyk Exp $ */ +/* $OpenBSD: vmd.c,v 1.62 2017/05/29 07:15:22 mlarkin Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -116,8 +116,11 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg) break; } id = vm->vm_vmid; - } else - vm = vm_getbyvmid(id); + } else if ((vm = vm_getbyvmid(id)) == NULL) { + res = ENOENT; + cmd = IMSG_VMDOP_TERMINATE_VM_RESPONSE; + break; + } if (vm_checkperm(vm, vid.vid_uid) != 0) { res = EPERM; cmd = IMSG_VMDOP_TERMINATE_VM_RESPONSE;