From: Roy Marples Date: Tue, 13 May 2008 11:24:16 +0000 (+0000) Subject: We shouldn't stamp on the dhcp message when checking overloads. X-Git-Tag: v4.0.2~424 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=854d14ce48ac9b5fc4ad521ab84798be68aefe29;p=thirdparty%2Fdhcpcd.git We shouldn't stamp on the dhcp message when checking overloads. --- diff --git a/dhcp.c b/dhcp.c index 3e894303..ec2359f9 100644 --- a/dhcp.c +++ b/dhcp.c @@ -241,6 +241,7 @@ _get_option(const struct dhcp_message *dhcp, uint8_t opt, int *type) const uint8_t *e = p + sizeof(dhcp->options); uint8_t l; uint8_t o = 0; + uint8_t overl = 0; while (p < e) { o = *p++; @@ -254,26 +255,22 @@ _get_option(const struct dhcp_message *dhcp, uint8_t opt, int *type) case DHCP_PAD: continue; case DHCP_END: - if (o) { - if (o & 1) { - /* bit 1 set means parse boot file */ - o &= ~1; - p = dhcp->bootfile; - e = p + sizeof(dhcp->bootfile); - } else if (o & 2) { - /* bit 2 set means parse server name */ - o &= ~2; - p = dhcp->servername; - e = p + sizeof(dhcp->servername); - } + if (overl & 1) { + /* bit 1 set means parse boot file */ + overl &= ~1; + p = dhcp->bootfile; + e = p + sizeof(dhcp->bootfile); + } else if (overl & 2) { + /* bit 2 set means parse server name */ + overl &= ~2; + p = dhcp->servername; + e = p + sizeof(dhcp->servername); } break; case DHCP_OPTIONSOVERLOADED: /* Ensure we only get this option once */ - if (!(o & 4)) { - o = p[1]; - o |= 4; - } + if (! overl) + overl = p[1]; break; }