diff options
| author | Roy Marples <roy@marples.name> | 2012-11-14 10:42:56 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2012-11-14 10:42:56 +0000 |
| commit | 6a7d194cb2645ee5d1e9443377d59cc5835d8e12 (patch) | |
| tree | 61ba57f34d1dc610bda336edbb4fe30f42a9cbb0 | |
| parent | 9adf0f1b0d4d9f985244cf82acd685e1f9cbb640 (diff) | |
| download | dhcpcd-6a7d194cb2645ee5d1e9443377d59cc5835d8e12.tar.xz | |
Ensure we have a big enough buffer for an escaped DNSSL option.
Conflicts:
ipv6rs.c
| -rw-r--r-- | dhcp.c | 2 | ||||
| -rw-r--r-- | dhcp.h | 1 | ||||
| -rw-r--r-- | ipv6rs.c | 12 |
3 files changed, 11 insertions, 4 deletions
@@ -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; @@ -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 *); @@ -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; } |
