diff options
author | kn <kn@openbsd.org> | 2019-10-25 09:57:33 +0000 |
---|---|---|
committer | kn <kn@openbsd.org> | 2019-10-25 09:57:33 +0000 |
commit | 4d52d473071764c3375738c0581198791429a0b2 (patch) | |
tree | fc91fce171fabadf453aa2d00548fce146e087e2 /usr.sbin/vmd | |
parent | Remove some space before tab and other small indentation errors. (diff) | |
download | wireguard-openbsd-4d52d473071764c3375738c0581198791429a0b2.tar.xz wireguard-openbsd-4d52d473071764c3375738c0581198791429a0b2.zip |
ifname in opentap() is not optional
The function argument is not checked at all and the only caller in config.c
always passes a buffer valid buffer.
Defer the error case's default value to the end to avoid rewriting in case
a node is opened.
Feedback and OK reyk
Diffstat (limited to 'usr.sbin/vmd')
-rw-r--r-- | usr.sbin/vmd/vmm.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index ab01e2589ce..bb3fdd75e0d 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.93 2019/06/28 13:32:51 deraadt Exp $ */ +/* $OpenBSD: vmm.c,v 1.94 2019/10/25 09:57:33 kn Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -590,7 +590,7 @@ terminate_vm(struct vm_terminate_params *vtp) * Opens the next available tap device, up to MAX_TAP. * * Parameters - * ifname: an optional buffer of at least IF_NAMESIZE bytes. + * ifname: a buffer of at least IF_NAMESIZE bytes. * * Returns a file descriptor to the tap node opened, or -1 if no tap * devices were available. @@ -601,16 +601,15 @@ opentap(char *ifname) int i, fd; char path[PATH_MAX]; - strlcpy(ifname, "tap", IF_NAMESIZE); for (i = 0; i < MAX_TAP; i++) { snprintf(path, PATH_MAX, "/dev/tap%d", i); fd = open(path, O_RDWR | O_NONBLOCK); if (fd != -1) { - if (ifname != NULL) - snprintf(ifname, IF_NAMESIZE, "tap%d", i); + snprintf(ifname, IF_NAMESIZE, "tap%d", i); return (fd); } } + strlcpy(ifname, "tap", IF_NAMESIZE); return (-1); } |