]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
dns_rdataslab_merge(): use dns_rdata_compare() instead of compare_rdata()
authorMichał Kępień <michal@isc.org>
Tue, 15 May 2018 06:18:01 +0000 (08:18 +0200)
committerMichał Kępień <michal@isc.org>
Tue, 15 May 2018 07:11:34 +0000 (09:11 +0200)
compare_rdata() was meant to be used as a qsort() callback.  Meanwhile,
dns_rdataslab_merge() calls compare_rdata() for a pair of dns_rdata_t
structures rather than a pair of struct xrdata structures, which is
harmless, but triggers an ubsan warning:

    rdataslab.c:84:33: runtime error: member access within address <address> with insufficient space for an object of type 'const struct xrdata'

Use dns_rdata_compare() instead of compare_rdata() to prevent the
warning from being triggered.

lib/dns/rdataslab.c

index 3df852e4254972dd3a465b4332c37275dd85dbc0..a442fe9d2998d2efbaa3a8786482ebe0a43ed73c 100644 (file)
@@ -796,7 +796,8 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
                else if (nadded == ncount)
                        fromold = ISC_TRUE;
                else
-                       fromold = ISC_TF(compare_rdata(&ordata, &nrdata) < 0);
+                       fromold = ISC_TF(dns_rdata_compare(&ordata,
+                                                          &nrdata) < 0);
                if (fromold) {
 #if DNS_RDATASET_FIXED
                        offsettable[oorder] = tcurrent - offsetbase;