From: Roy Marples Date: Fri, 16 Jun 2017 09:20:15 +0000 (+0100) Subject: Now print_option is fully checked, we can avoid a malloc here now. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d7318eaf52e59fdcff6c472ef8adafd5dbf2069;p=thirdparty%2Fdhcpcd.git Now print_option is fully checked, we can avoid a malloc here now. --- diff --git a/src/dhcp-common.c b/src/dhcp-common.c index c40ca0be..bf8e87a4 100644 --- a/src/dhcp-common.c +++ b/src/dhcp-common.c @@ -672,16 +672,13 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt, char *tmp; if (opt->type & OT_RFC1035) { - sl = decode_rfc1035(NULL, 0, data, dl); + sl = decode_rfc1035(s, len, data, dl); if (sl == 0 || sl == -1) return sl; - l = (size_t)sl + 1; - tmp = malloc(l); - if (tmp == NULL) - return -1; - decode_rfc1035(tmp, l, data, dl); - sl = print_string(s, len, opt->type, (uint8_t *)tmp, l - 1); - free(tmp); + if (s != NULL) { + if (valid_domainname(s, opt->type) == -1) + return -1; + } return sl; }