Commit 486bcd5a authored by Kurt H Maier's avatar Kurt H Maier Committed by Simon Kelley

Simplify and correct bindtodevice().

parent be9a74d2
...@@ -485,11 +485,8 @@ char *whichdevice(void) ...@@ -485,11 +485,8 @@ char *whichdevice(void)
void bindtodevice(char *device, int fd) void bindtodevice(char *device, int fd)
{ {
struct ifreq ifr;
strcpy(ifr.ifr_name, device);
/* only allowed by root. */ /* 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) errno != EPERM)
die(_("failed to set SO_BINDTODEVICE on DHCP socket: %s"), NULL, EC_BADNET); die(_("failed to set SO_BINDTODEVICE on DHCP socket: %s"), NULL, EC_BADNET);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment