summaryrefslogtreecommitdiffhomepage
path: root/src/dhcpv4.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r--src/dhcpv4.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index 4b69467..53e4682 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -362,14 +362,16 @@ static void handle_dhcpv4(void *addr, void *data, size_t len,
dhcpv4_put(&reply, &cookie, DHCPV4_OPT_MTU, 2, &mtu);
}
- if (iface->search) {
- char b[256];
- if (dn_expand(iface->search, iface->search + iface->search_len,
- iface->search, b, sizeof(b)) > 0)
- dhcpv4_put(&reply, &cookie, DHCPV4_OPT_DOMAIN, strlen(b), b);
+ if (iface->search && iface->search_len <= 255) {
+ dhcpv4_put(&reply, &cookie, DHCPV4_OPT_SEARCH_DOMAIN,
+ iface->search_len, iface->search);
} else if (!res_init() && _res.dnsrch[0] && _res.dnsrch[0][0]) {
- dhcpv4_put(&reply, &cookie, DHCPV4_OPT_DOMAIN,
- strlen(_res.dnsrch[0]), _res.dnsrch[0]);
+ uint8_t search_buf[256];
+ int len = dn_comp(_res.dnsrch[0], search_buf,
+ sizeof(search_buf), NULL, NULL);
+ if (len > 0)
+ dhcpv4_put(&reply, &cookie, DHCPV4_OPT_SEARCH_DOMAIN,
+ len, search_buf);
}
dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER, 4, &ifaddr.sin_addr);