dns: fix non-NULL terminated C-string 77/22577/2
authorBenoît Ganne <bganne@cisco.com>
Mon, 30 Sep 2019 08:13:27 +0000 (10:13 +0200)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Tue, 8 Oct 2019 06:39:56 +0000 (06:39 +0000)
Type: fix

Change-Id: Ib030e6ac3386528901e0805d1ffe2eec033d819f
Signed-off-by: Benoît Ganne <bganne@cisco.com>
(cherry picked from commit 328c08d603bb0a9956b82553f1691fd8a5a5de7d)

src/plugins/dns/dns.c

index 5c51a44..870cfae 100644 (file)
@@ -816,6 +816,8 @@ dns_add_static_entry (dns_main_t * dm, u8 * name, u8 * dns_reply_data)
 
   /* Note: consumes the name vector */
   ep->name = name;
+  /* make sure it NULL-terminated as hash_set_mem will use strlen() */
+  vec_terminate_c_string (ep->name);
   hash_set_mem (dm->cache_entry_by_name, ep->name, ep - dm->entries);
   ep->flags = DNS_CACHE_ENTRY_FLAG_VALID | DNS_CACHE_ENTRY_FLAG_STATIC;
   ep->dns_response = dns_reply_data;