summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-11-14 10:42:56 +0000
committerRoy Marples <roy@marples.name>2012-11-14 10:42:56 +0000
commit6a7d194cb2645ee5d1e9443377d59cc5835d8e12 (patch)
tree61ba57f34d1dc610bda336edbb4fe30f42a9cbb0
parent9adf0f1b0d4d9f985244cf82acd685e1f9cbb640 (diff)
downloaddhcpcd-6a7d194cb2645ee5d1e9443377d59cc5835d8e12.tar.xz
Ensure we have a big enough buffer for an escaped DNSSL option.
Conflicts: ipv6rs.c
-rw-r--r--dhcp.c2
-rw-r--r--dhcp.h1
-rw-r--r--ipv6rs.c12
3 files changed, 11 insertions, 4 deletions
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;
}