Commit c56eb573 authored by Stefan Brüns's avatar Stefan Brüns Committed by Joe Hershberger

net: Fix parsing of Bootp/DHCP option 0 (Pad)

Pad has no len byte, so the normal parsing code fails.
Signed-off-by: default avatarStefan Brüns <stefan.bruens@rwth-aachen.de>
Acked-by: default avatarJoe Hershberger <joe.hershberger@ni.com>
parent 454d9d3e
......@@ -776,6 +776,9 @@ static void dhcp_process_options(uchar *popt, struct bootp_hdr *bp)
while (popt < end && *popt != 0xff) {
oplen = *(popt + 1);
switch (*popt) {
case 0:
oplen = -1; /* Pad omits len byte */
break;
case 1:
net_copy_ip(&net_netmask, (popt + 2));
break;
......@@ -879,7 +882,13 @@ static int dhcp_message_type(unsigned char *popt)
while (*popt != 0xff) {
if (*popt == 53) /* DHCP Message Type */
return *(popt + 2);
popt += *(popt + 1) + 2; /* Scan through all options */
if (*popt == 0) {
/* Pad */
popt += 1;
} else {
/* Scan through all options */
popt += *(popt + 1) + 2;
}
}
return -1;
}
......
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