diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2017-05-29 07:15:23 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2017-05-29 07:15:23 +0000 |
commit | f8641721dac0f00dfe1d895e09f0142aa0986c46 (patch) | |
tree | fe73aefd4745f949e2b18d445af99c9d37a180c5 | |
parent | 622d3015e4e9f8bedc4e82d64cf79d02403817af (diff) |
vmd(8): prevent crashing when presented with a vm name argument to
"vmctl stop" that doesn't exist.
Diff from Pratik Vyas, thanks!
-rw-r--r-- | usr.sbin/vmd/vmd.c | 9 |
1 files changed, 6 insertions, 3 deletions
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 <reyk@openbsd.org> @@ -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; |