From: Willem Toorop Date: Wed, 21 Jan 2026 09:32:42 +0000 (+0100) Subject: Skip memcpy if nothing to be copied X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee714dd313aa62c8041bd9db167d007a8d95cdfd;p=thirdparty%2Fldns.git Skip memcpy if nothing to be copied This came out of running ldns-nsec3-hash with ldns compiled with -fsanitize=address,undefined --- diff --git a/dnssec.c b/dnssec.c index 1339e73c..5b5d5699 100644 --- a/dnssec.c +++ b/dnssec.c @@ -1047,7 +1047,9 @@ ldns_nsec3_hash_name(const ldns_rdf *name, return NULL; } memcpy(hashed_owner_str, ldns_rdf_data(cann), ldns_rdf_size(cann)); - memcpy(hashed_owner_str + ldns_rdf_size(cann), salt, salt_length); + if (salt_length) { + memcpy(hashed_owner_str + ldns_rdf_size(cann), salt, salt_length); + } ldns_rdf_deep_free(cann); for (cur_it = iterations + 1; cur_it > 0; cur_it--) { @@ -1061,7 +1063,9 @@ ldns_nsec3_hash_name(const ldns_rdf *name, return NULL; } memcpy(hashed_owner_str, hash, LDNS_SHA1_DIGEST_LENGTH); - memcpy(hashed_owner_str + LDNS_SHA1_DIGEST_LENGTH, salt, salt_length); + if (salt_length) { + memcpy(hashed_owner_str + LDNS_SHA1_DIGEST_LENGTH, salt, salt_length); + } hashed_owner_str_len = LDNS_SHA1_DIGEST_LENGTH + salt_length; }