From: Willem Toorop Date: Sun, 21 Dec 2025 14:32:09 +0000 (+0100) Subject: 2nd arg to memcpy may be NULL if size is 0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d04a8d9badc0156650c2a1774c6d36f26f816f51;p=thirdparty%2Fldns.git 2nd arg to memcpy may be NULL if size is 0 Found with ldns_native2rdf_int16_data(0, NULL) being called from ldns_pkt_tsig_sign_next() --- diff --git a/Changelog b/Changelog index a44ac76e..6106b66b 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,8 @@ * Fix #290: ldns-verify-zone prints to stdout instead of myerr Thanks RoyArends * Fix memory leak in ldns-notify + * Prevent "null pointer pass as 2nd argument to memcpy" runtime + error, when size is 0 1.9.0 2025-12-04 * PR #246: Make ldns_calc_keytag() available for CDNSKEY RR diff --git a/rdata.c b/rdata.c index 5befc9e7..429d109e 100644 --- a/rdata.c +++ b/rdata.c @@ -167,7 +167,9 @@ ldns_native2rdf_int16_data(size_t size, uint8_t *data) return NULL; } ldns_write_uint16(rdf_data, size); - memcpy(rdf_data + 2, data, size); + if (size) { + memcpy(rdf_data + 2, data, size); + } rdf = ldns_rdf_new(LDNS_RDF_TYPE_INT16_DATA, size + 2, rdf_data); if(!rdf) LDNS_FREE(rdf_data);