]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Skip memcpy if nothing to be copied
authorWillem Toorop <willem@nlnetlabs.nl>
Wed, 21 Jan 2026 09:32:42 +0000 (10:32 +0100)
committerWillem Toorop <willem@nlnetlabs.nl>
Wed, 21 Jan 2026 09:32:42 +0000 (10:32 +0100)
This came out of running ldns-nsec3-hash with ldns compiled with -fsanitize=address,undefined

dnssec.c

index 1339e73c3c78f641bca0317c48fd9b1694b9e306..5b5d5699d1269e1327f1ec26aba17c02506e5943 100644 (file)
--- 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;
        }