]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure we have a big enough buffer for an escaped DNSSL option.
authorRoy Marples <roy@marples.name>
Wed, 14 Nov 2012 10:42:56 +0000 (10:42 +0000)
committerRoy Marples <roy@marples.name>
Wed, 14 Nov 2012 10:42:56 +0000 (10:42 +0000)
Conflicts:
ipv6rs.c

dhcp.c
dhcp.h
ipv6rs.c

diff --git a/dhcp.c b/dhcp.c
index 640dd2149a225bceb801c173c54975d590c20367..35efae30b0e5757ffb7452db811c6257b17a43c7 100644 (file)
--- 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 fb27e71ba891566c42a6f1e074f06227b75d738d..2d8dcea9196294bc16fc7294dc1dbda8f31d35d9 100644 (file)
--- 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 *);
 
index 2efac06e557379cda2992cb88f92ebdc1ca75855..121f16cae126186518e4c12e02b48cd909d9ffc6 100644 (file)
--- 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;
                }