diff options
| author | Roy Marples <roy@marples.name> | 2009-01-30 20:18:35 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-01-30 20:18:35 +0000 |
| commit | de82635c0435bf5b36f3e45f72138f543cd2e908 (patch) | |
| tree | a36a578d8fec5a955fb6ba3606d514b651675ac1 | |
| parent | 41f9654ae9882838c96ba86cb567c3892fa7702a (diff) | |
| download | dhcpcd-de82635c0435bf5b36f3e45f72138f543cd2e908.tar.xz | |
We should zero the entire message struct so any options don't overflow into unallocated memory when evaluating them.
| -rw-r--r-- | dhcpcd.c | 10 |
1 files changed, 1 insertions, 9 deletions
@@ -562,7 +562,6 @@ handle_dhcp_packet(void *arg) uint8_t *packet; struct dhcp_message *dhcp = NULL; const uint8_t *pp; - uint8_t *p; ssize_t bytes; /* We loop through until our buffer is empty. @@ -583,7 +582,7 @@ handle_dhcp_packet(void *arg) continue; } if (!dhcp) - dhcp = xmalloc(sizeof(*dhcp)); + dhcp = xzalloc(sizeof(*dhcp)); memcpy(dhcp, pp, bytes); if (dhcp->cookie != htonl(MAGIC_COOKIE)) { syslog(LOG_DEBUG, "%s: bogus cookie, ignoring", @@ -607,13 +606,6 @@ handle_dhcp_packet(void *arg) hwaddr_ntoa(dhcp->chaddr, sizeof(dhcp->chaddr))); continue; } - /* We should ensure that the packet is terminated correctly - * if we have space for the terminator */ - if ((size_t)bytes != sizeof(*dhcp)) { - p = (uint8_t *)dhcp + (bytes - 1); - if (*p != DHO_END) - *++p = DHO_END; - } handle_dhcp(iface, &dhcp); if (iface->raw_fd == -1) break; |
