Import dhcpcd-4.0.13

Fixed since dhcpcd-4.0.12 include
 * Every DHCP message now requires a ServerID as some rogue DHCP servers
   NAK without one.
 * Extra UDP validation is now done for testing dhcpcd over a loopback
This commit is contained in:
roy 2009-04-17 20:05:27 +00:00
parent 9c07c1c9a8
commit be69da1d06
7 changed files with 39 additions and 33 deletions

View File

@ -1389,7 +1389,12 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp,
/* We have to have DHCP type to work */
if (get_option_uint8(&type, dhcp, DHO_MESSAGETYPE) == -1) {
log_dhcp(LOG_ERR, "no DHCP type in", dhcp);
logger(LOG_ERR, "ignoring message; no DHCP type");
return 0;
}
/* Every DHCP message should include ServerID */
if (get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == -1) {
logger(LOG_ERR, "ignoring message; no Server ID");
return 0;
}
@ -1548,7 +1553,7 @@ handle_dhcp_packet(struct if_state *state, const struct options *options)
}
if (bytes == -1)
break;
if (valid_udp_packet(packet) == -1)
if (valid_udp_packet(packet, bytes) == -1)
continue;
bytes = get_udp_data(&pp, packet);
if ((size_t)bytes > sizeof(*dhcp)) {

View File

@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
#define VERSION "4.0.12"
#define VERSION "4.0.13"
/*
* By default we don't add a local link route if we got a routeable address.

View File

@ -24,6 +24,7 @@
.\"
.Dd August 14, 2008
.Dt DHCPCD.SH 8 SMM
.Os
.Sh NAME
.Nm dhcpcd-run-hooks
.Nd DHCP client configuration script

View File

@ -24,6 +24,7 @@
.\"
.Dd November 18, 2008
.Dt DHCPCD 8 SMM
.Os
.Sh NAME
.Nm dhcpcd
.Nd an RFC 2131 compliant DHCP client
@ -335,7 +336,7 @@ sends a default
.Ar clientid
of the hardware family and the hardware address.
.El
.Ss Restriciting behaviour
.Ss Restricting behaviour
.Nm
will try to do as much as it can by default.
However, there are sometimes situations where you don't want the things to be

View File

@ -24,6 +24,7 @@
.\"
.Dd November 18, 2008
.Dt DHCPCD.CONF 5 SMM
.Os
.Sh NAME
.Nm dhcpcd.conf
.Nd dhcpcd configuration file

View File

@ -634,44 +634,42 @@ get_udp_data(const uint8_t **data, const uint8_t *udp)
}
int
valid_udp_packet(const uint8_t *data)
valid_udp_packet(const uint8_t *data, size_t data_len)
{
struct udp_dhcp_packet packet;
uint16_t bytes;
uint16_t ipsum;
uint16_t iplen;
uint16_t udpsum;
struct in_addr source;
struct in_addr dest;
int retval = 0;
uint16_t bytes, udpsum;
memcpy(&packet, data, sizeof(packet));
bytes = ntohs(packet.ip.ip_len);
ipsum = packet.ip.ip_sum;
iplen = packet.ip.ip_len;
udpsum = packet.udp.uh_sum;
if (0 != checksum(&packet.ip, sizeof(packet.ip))) {
if (data_len > sizeof(packet)) {
errno = EINVAL;
return -1;
}
memcpy(&packet, data, data_len);
if (checksum(&packet.ip, sizeof(packet.ip)) != 0) {
errno = EINVAL;
return -1;
}
packet.ip.ip_sum = 0;
memcpy(&source, &packet.ip.ip_src, sizeof(packet.ip.ip_src));
memcpy(&dest, &packet.ip.ip_dst, sizeof(packet.ip.ip_dst));
memset(&packet.ip, 0, sizeof(packet.ip));
packet.udp.uh_sum = 0;
packet.ip.ip_p = IPPROTO_UDP;
memcpy(&packet.ip.ip_src, &source, sizeof(packet.ip.ip_src));
memcpy(&packet.ip.ip_dst, &dest, sizeof(packet.ip.ip_dst));
packet.ip.ip_len = packet.udp.uh_ulen;
if (udpsum && udpsum != checksum(&packet, bytes)) {
bytes = ntohs(packet.ip.ip_len);
if (data_len < bytes) {
errno = EINVAL;
retval = -1;
return -1;
}
udpsum = packet.udp.uh_sum;
packet.udp.uh_sum = 0;
packet.ip.ip_hl = 0;
packet.ip.ip_v = 0;
packet.ip.ip_tos = 0;
packet.ip.ip_len = packet.udp.uh_ulen;
packet.ip.ip_id = 0;
packet.ip.ip_off = 0;
packet.ip.ip_ttl = 0;
packet.ip.ip_sum = 0;
if (udpsum && checksum(&packet, bytes) != udpsum) {
errno = EINVAL;
return -1;
}
return retval;
return 0;
}
int

View File

@ -160,7 +160,7 @@ const size_t udp_dhcp_len;
ssize_t make_udp_packet(uint8_t **, const uint8_t *, size_t,
struct in_addr, struct in_addr);
ssize_t get_udp_data(const uint8_t **, const uint8_t *);
int valid_udp_packet(const uint8_t *);
int valid_udp_packet(const uint8_t *, size_t);
int open_socket(struct interface *, int);
ssize_t send_packet(const struct interface *, struct in_addr,