discover/network: Ensure dns config buffer contains a trailling nul
authorJeremy Kerr <jk@ozlabs.org>
Fri, 18 Oct 2013 03:31:57 +0000 (11:31 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 21 Oct 2013 11:30:08 +0000 (19:30 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/network.c

index 9aa975204e0f71de40070340e506d1f3ed6dd3e4..edb7358b5c36618cc6ee46d94cb7e1fb2f789483 100644 (file)
@@ -480,9 +480,10 @@ static void network_init_dns(struct network *network)
                }
 
                dns_conf_len = strlen(dns_conf);
                }
 
                dns_conf_len = strlen(dns_conf);
-               buf = talloc_realloc(network, buf, char, len + dns_conf_len);
+               buf = talloc_realloc(network, buf, char, len + dns_conf_len + 1);
                memcpy(buf + len, dns_conf, dns_conf_len);
                len += dns_conf_len;
                memcpy(buf + len, dns_conf, dns_conf_len);
                len += dns_conf_len;
+               buf[len - 1] = '\0';
                modified = true;
 
                talloc_free(dns_conf);
                modified = true;
 
                talloc_free(dns_conf);