if (iface->fd >= 0) close (iface->fd); \
iface->fd = -1; \
if (_mode == SOCKET_OPEN) \
- if (open_socket (iface, false) < 0) { retval = -1; goto eexit; } \
+ if (open_socket (iface, false) < 0) { retval = EXIT_FAILURE; goto eexit; } \
mode = _mode; \
}
else {
logger (LOG_ERR, "timed out");
if (! daemonised) {
- retval = -1;
+ retval = EXIT_FAILURE;
goto eexit;
}
}
xid = 0;
if (configure (options, iface, dhcp) < 0 && ! daemonised) {
- retval = -1;
+ retval = EXIT_FAILURE;
goto eexit;
}
if (! daemonised && options->daemonise) {
if ((daemonise (options->pidfile)) < 0 ) {
- retval = -1;
+ retval = EXIT_FAILURE;
goto eexit;
}
daemonised = true;
} else {
/* An error occured. As we heavily depend on select, we abort. */
logger (LOG_ERR, "error on select: %s", strerror (errno));
- retval = -1;
+ retval = EXIT_FAILURE;
goto eexit;
}
}
p += iface->hwlen;
}
- *p++ = DHCP_END;
-
#ifdef BOOTP_MESSAGE_LENTH_MIN
/* Some crappy DHCP servers think they have to obey the BOOTP minimum
* messag length. They are wrong, but we should still cater for them */
- while (p - m < BOOTP_MESSAGE_LENTH_MIN)
+ while (p - m < BOOTP_MESSAGE_LENTH_MIN - 1)
*p++ = DHCP_PAD;
#endif
+ *p++ = DHCP_END;
message_length = p - m;
memset (&packet, 0, sizeof (struct udp_dhcp_packet));
if (dstd)
free (dstd);
- if ((s = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
+ if ((s = socket (PF_ROUTE, SOCK_RAW, 0)) < 0) {
logger (LOG_ERR, "socket: %s", strerror (errno));
return -1;
}
if (getifaddrs (&ifap)) {
logger (LOG_ERR, "getifaddrs: %s", strerror (errno));
+ close (s);
return -1;
}