-/* $OpenBSD: config.c,v 1.68 2023/02/22 10:04:45 mbuhl Exp $ */
+/* $OpenBSD: config.c,v 1.69 2023/04/02 02:04:10 dv Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
}
/* Open TTY */
- if (vm->vm_ttyname == NULL) {
+ if (vm->vm_ttyname[0] == '\0') {
if (vm_opentty(vm) == -1) {
log_warn("%s: can't open tty %s", __func__,
- vm->vm_ttyname == NULL ? "" : vm->vm_ttyname);
+ vm->vm_ttyname[0] == '\0' ? "" : vm->vm_ttyname);
goto fail;
}
}
-/* $OpenBSD: vmd.c,v 1.138 2023/01/28 14:40:53 dv Exp $ */
+/* $OpenBSD: vmd.c,v 1.139 2023/04/02 02:04:10 dv Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
memcpy(&vir, imsg->data, sizeof(vir));
if ((vm = vm_getbyvmid(vir.vir_info.vir_id)) != NULL) {
memset(vir.vir_ttyname, 0, sizeof(vir.vir_ttyname));
- if (vm->vm_ttyname != NULL)
+ if (vm->vm_ttyname[0] != '\0')
strlcpy(vir.vir_ttyname, vm->vm_ttyname,
sizeof(vir.vir_ttyname));
log_debug("%s: running vm: %d, vm_state: 0x%x",
vm->vm_tty = ptm.cfd;
close(ptm.sfd);
- if ((vm->vm_ttyname = strdup(ptm.sn)) == NULL)
+ if (strlcpy(vm->vm_ttyname, ptm.sn, sizeof(vm->vm_ttyname))
+ >= sizeof(vm->vm_ttyname)) {
+ log_warnx("%s: truncated ttyname", __func__);
goto fail;
+ }
uid = vm->vm_uid;
gid = vm->vm_params.vmc_owner.gid;
close(vm->vm_tty);
vm->vm_tty = -1;
}
- free(vm->vm_ttyname);
- vm->vm_ttyname = NULL;
+ memset(&vm->vm_ttyname, 0, sizeof(vm->vm_ttyname));
}
void
vm_remove(vm, caller);
}
}
-
-/* $OpenBSD: vmd.h,v 1.114 2023/01/28 14:40:53 dv Exp $ */
+/* $OpenBSD: vmd.h,v 1.115 2023/04/02 02:04:10 dv Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
int vm_cdrom;
int vm_disks[VM_MAX_DISKS_PER_VM][VM_MAX_BASE_PER_DISK];
struct vmd_if vm_ifs[VM_MAX_NICS_PER_VM];
- char *vm_ttyname;
+ char vm_ttyname[VM_TTYNAME_MAX];
int vm_tty;
uint32_t vm_peerid;
/* When set, VM was defined in a config file */