From: Frank Denis Date: Sun, 20 Nov 2016 16:55:09 +0000 (+0100) Subject: Do not allow empty names in `ldns_dname_new()` X-Git-Tag: release-1.7.0-rc1~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1%2Fhead;p=thirdparty%2Fldns.git 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. --- 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;