From 97b222de0730dada823999e4ac00dabab9478035 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 20 Nov 2016 17:55:09 +0100 Subject: [PATCH] Do not allow empty names in `ldns_dname_new()` A name has to be at least 1 byte, so return `NULL` if this is not the case. Before that change, we had a paradoxical situation where `ldns_dname_new(0, NULL)` returned a valid RDF pointer, but trying to use that pointer with functions such as `ldns_rdf_print()` had an undefined behavior. --- dname.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dname.c b/dname.c index 6701ba7d..1c41b7c7 100644 --- a/dname.c +++ b/dname.c @@ -251,6 +251,9 @@ ldns_dname_new(uint16_t s, void *d) { ldns_rdf *rd; + if (!s || !d) { + return NULL; + } rd = LDNS_MALLOC(ldns_rdf); if (!rd) { return NULL; -- 2.47.3