From b7beaca8605903f5ea3f401d6c7b4403ac0bba65 Mon Sep 17 00:00:00 2001 From: Kevin Darbyshire-Bryant Date: Wed, 10 Apr 2013 11:35:45 +0100 Subject: [PATCH] dnsmasq 2.66rc5 fix lease file parsing bug --- release/src/router/dnsmasq/VERSION | 2 +- release/src/router/dnsmasq/man/dnsmasq.8 | 4 ++-- release/src/router/dnsmasq/src/dnsmasq.h | 1 + release/src/router/dnsmasq/src/forward.c | 2 +- release/src/router/dnsmasq/src/helper.c | 10 ++++++++-- release/src/router/dnsmasq/src/lease.c | 2 +- release/src/router/dnsmasq/src/rfc3315.c | 6 +++--- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/release/src/router/dnsmasq/VERSION b/release/src/router/dnsmasq/VERSION index 91e199cbed..998eb1f640 100644 --- a/release/src/router/dnsmasq/VERSION +++ b/release/src/router/dnsmasq/VERSION @@ -1 +1 @@ -2.66rc4 +$Format:%d$ diff --git a/release/src/router/dnsmasq/man/dnsmasq.8 b/release/src/router/dnsmasq/man/dnsmasq.8 index deb3b530bb..12828a19c1 100644 --- a/release/src/router/dnsmasq/man/dnsmasq.8 +++ b/release/src/router/dnsmasq/man/dnsmasq.8 @@ -589,7 +589,7 @@ included and configured. This option cannot be combined with .TP .B \-F, --dhcp-range=[tag:[,tag:],][set:,][,][,][,[,]][,] .TP -.B \-F, --dhcp-range=[tag:[,tag:],][set:,][,|constuctor:][,][,][,] +.B \-F, --dhcp-range=[tag:[,tag:],][set:,][,|constructor:][,][,][,] Enable the DHCP server. Addresses will be given out from the range to and from statically defined addresses given @@ -625,7 +625,7 @@ IPv6 (only) supports another type of range. In this, the start address and optio .B constructor:. This forms a template which describes how to create ranges, based on the addresses assigned to the interface. For instance -.B --dhcp-range=::1,::4,constructor:eth0 +.B --dhcp-range=::1,::400,constructor:eth0 will look for addreses of the form ::1 on eth0 and then create a range from ::1 to ::400. If the interface is assigned more than one network, then the corresponding ranges will be automatically created, and then deprecated and finally removed again as the address is deprecated and then deleted. The interface name may have a final "*" wildcard. diff --git a/release/src/router/dnsmasq/src/dnsmasq.h b/release/src/router/dnsmasq/src/dnsmasq.h index 81edf71984..58a3d3323c 100644 --- a/release/src/router/dnsmasq/src/dnsmasq.h +++ b/release/src/router/dnsmasq/src/dnsmasq.h @@ -550,6 +550,7 @@ struct dhcp_lease { int backoff; /* zero -> confirmed */ struct slaac_address *next; } *slaac_address; + int vendorclass_count; #endif struct dhcp_lease *next; }; diff --git a/release/src/router/dnsmasq/src/forward.c b/release/src/router/dnsmasq/src/forward.c index 9a1e15a75e..1ea25ddc7a 100644 --- a/release/src/router/dnsmasq/src/forward.c +++ b/release/src/router/dnsmasq/src/forward.c @@ -680,7 +680,7 @@ void receive_query(struct listener *listen, time_t now) dst_addr_4.s_addr = 0; netmask.s_addr = 0; - if (listen->iface && option_bool(OPT_NOWILD)) + if (option_bool(OPT_NOWILD) && listen->iface) { auth_dns = listen->iface->dns_auth; diff --git a/release/src/router/dnsmasq/src/helper.c b/release/src/router/dnsmasq/src/helper.c index 94aabebf7a..ab691b7f51 100644 --- a/release/src/router/dnsmasq/src/helper.c +++ b/release/src/router/dnsmasq/src/helper.c @@ -655,8 +655,9 @@ void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t n unsigned char *p; unsigned int hostname_len = 0, clid_len = 0, ed_len = 0; int fd = daemon->dhcpfd; +#ifdef HAVE_DHCP6 + int is6 = !!(lease->flags & (LEASE_TA | LEASE_NA)); -#ifdef HAVE_DHCP6 if (!daemon->dhcp) fd = daemon->dhcp6fd; #endif @@ -676,7 +677,12 @@ void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t n buf->action = action; buf->flags = lease->flags; - buf->hwaddr_len = lease->hwaddr_len; +#ifdef HAVE_DHCP6 + if (is6) + buf->hwaddr_len = lease->vendorclass_count; + else +#endif + buf->hwaddr_len = lease->hwaddr_len; buf->hwaddr_type = lease->hwaddr_type; buf->clid_len = clid_len; buf->ed_len = ed_len; diff --git a/release/src/router/dnsmasq/src/lease.c b/release/src/router/dnsmasq/src/lease.c index 15238214a5..0293b1035d 100644 --- a/release/src/router/dnsmasq/src/lease.c +++ b/release/src/router/dnsmasq/src/lease.c @@ -115,7 +115,7 @@ void lease_init(time_t now) s++; } - hw_type = atoi(s); + hw_type = strtoul(s, NULL, 10); if ((lease = lease6_allocate(&addr.addr.addr6, lease_type))) { diff --git a/release/src/router/dnsmasq/src/rfc3315.c b/release/src/router/dnsmasq/src/rfc3315.c index 9d11fe1f83..c8ba3d0090 100644 --- a/release/src/router/dnsmasq/src/rfc3315.c +++ b/release/src/router/dnsmasq/src/rfc3315.c @@ -1609,12 +1609,12 @@ static void update_leases(struct state *state, struct dhcp_context *context, str free(lease->extradata); lease->extradata = NULL; lease->extradata_size = lease->extradata_len = 0; - lease->hwaddr_len = 0; /* surrogate for no of vendor classes */ + lease->vendorclass_count = 0; if ((class_opt = opt6_find(state->packet_options, state->end, OPTION6_VENDOR_CLASS, 4))) { void *enc_opt, *enc_end = opt6_ptr(class_opt, opt6_len(class_opt)); - lease->hwaddr_len++; + lease->vendorclass_count++; /* send enterprise number first */ sprintf(daemon->dhcp_buff2, "%u", opt6_uint(class_opt, 0, 4)); lease_add_extradata(lease, (unsigned char *)daemon->dhcp_buff2, strlen(daemon->dhcp_buff2), 0); @@ -1622,7 +1622,7 @@ static void update_leases(struct state *state, struct dhcp_context *context, str if (opt6_len(class_opt) >= 6) for (enc_opt = opt6_ptr(class_opt, 4); enc_opt; enc_opt = opt6_next(enc_opt, enc_end)) { - lease->hwaddr_len++; + lease->vendorclass_count++; lease_add_extradata(lease, opt6_ptr(enc_opt, 0), opt6_len(enc_opt), 0); } } -- 2.11.4.GIT