From 486bcd5a7b533549257e8cf59214a2f2c099faf9 Mon Sep 17 00:00:00 2001 From: Kurt H Maier Date: Fri, 26 Jan 2018 15:10:59 +0000 Subject: [PATCH] Simplify and correct bindtodevice(). --- src/dhcp-common.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/dhcp-common.c b/src/dhcp-common.c index 9e5bfce..d9719d1 100644 --- a/src/dhcp-common.c +++ b/src/dhcp-common.c @@ -485,11 +485,8 @@ char *whichdevice(void) void bindtodevice(char *device, int fd) { - struct ifreq ifr; - - strcpy(ifr.ifr_name, device); /* only allowed by root. */ - if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)) == -1 && + if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, device, IFNAMSIZ) == -1 && errno != EPERM) die(_("failed to set SO_BINDTODEVICE on DHCP socket: %s"), NULL, EC_BADNET); }