]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
libknot/edns: fix null pointer passed to memcpy (UBSAN)
authorDaniel Salzman <daniel.salzman@nic.cz>
Mon, 12 Apr 2021 07:19:22 +0000 (09:19 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Mon, 12 Apr 2021 07:19:59 +0000 (09:19 +0200)
src/libknot/rrtype/opt.c

index b9a8c309afe573b42ac0b3ba50d3307d0b32d445..6733e94c0db5583387d8e64f1b05cdc7bb304108 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2020 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -208,7 +208,9 @@ int knot_edns_add_option(knot_rrset_t *opt_rr, uint16_t code,
                return KNOT_ENOMEM;
        }
 
-       memcpy(wire, data, size);
+       if (size > 0) {
+               memcpy(wire, data, size);
+       }
 
        return KNOT_EOK;
 }