Mercurial > hg > dhcpcd
changeset 4278:7263f7c073b4 draft
dhcp: Clarify range checks in valid UDP packets
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 07 May 2018 15:01:46 +0100 |
| parents | 97f2363a60cf |
| children | cdffb0137daa |
| files | src/dhcp.c |
| diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcp.c Sun May 06 16:50:35 2018 +0100 +++ b/src/dhcp.c Mon May 07 15:01:46 2018 +0100 @@ -3276,7 +3276,7 @@ struct bootp_pkt *p; uint16_t bytes; - if (data_len < sizeof(p->ip) + sizeof(p->udp)) { + if (data_len < sizeof(p->ip)) { if (from) from->s_addr = INADDR_ANY; errno = ERANGE; @@ -3291,6 +3291,12 @@ } bytes = ntohs(p->ip.ip_len); + /* Check we have a payload */ + if (bytes <= sizeof(p->ip) + sizeof(p->udp)) { + errno = ERANGE; + return -1; + } + /* Check we don't go beyond the payload */ if (bytes > data_len) { errno = ENOBUFS; return -1;
