From: Roy Marples Date: Wed, 14 Nov 2012 10:42:56 +0000 (+0000) Subject: Ensure we have a big enough buffer for an escaped DNSSL option. X-Git-Tag: v5.6.3~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a7d194cb2645ee5d1e9443377d59cc5835d8e12;p=thirdparty%2Fdhcpcd.git Ensure we have a big enough buffer for an escaped DNSSL option. Conflicts: ipv6rs.c --- diff --git a/dhcp.c b/dhcp.c index 640dd214..35efae30 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1185,7 +1185,7 @@ read_lease(const struct interface *iface) return dhcp; } -static ssize_t +ssize_t print_string(char *s, ssize_t len, int dl, const uint8_t *data) { uint8_t c; diff --git a/dhcp.h b/dhcp.h index fb27e71b..2d8dcea9 100644 --- a/dhcp.h +++ b/dhcp.h @@ -189,6 +189,7 @@ int get_option_uint8(uint8_t *, const struct dhcp_message *, uint8_t); struct rt *get_option_routes(const struct dhcp_message *, const char *, unsigned long long *); ssize_t decode_rfc3397(char *, ssize_t, int, const uint8_t *); +ssize_t print_string(char *, ssize_t, int, const uint8_t *); ssize_t configure_env(char **, const char *, const struct dhcp_message *, const struct if_options *); diff --git a/ipv6rs.c b/ipv6rs.c index 2efac06e..121f16ca 100644 --- a/ipv6rs.c +++ b/ipv6rs.c @@ -399,7 +399,7 @@ ipv6rs_handledata(_unused void *arg) struct nd_opt_hdr *ndo; struct ra_opt *rao; struct ipv6_addr *ap; - char *opt; + char *opt, *tmp; struct timeval expire; uint8_t has_prefix, has_dns, new_rap, new_data; @@ -665,8 +665,14 @@ ipv6rs_handledata(_unused void *arg) syslog(LOG_ERR, "%s: invalid DNSSL option", ifp->name); } else { - opt = xmalloc(l); - decode_rfc3397(opt, l, n, op); + tmp = xmalloc(l); + decode_rfc3397(tmp, l, n, op); + n = print_string(NULL, 0, + l - 1, (const uint8_t *)tmp); + opt = xmalloc(n); + print_string(opt, n, + l - 1, (const uint8_t *)tmp); + free(tmp); } break; }