From f55dc51f42576fbbc5912a3fbb77e156158b844b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 26 Sep 2019 14:47:04 +0200 Subject: [PATCH 01/30] Add Cppcheck job to the CI This MR changes the default Debian sid build to wrap make with bear that creates compilation database and use the compilation database to run Cppcheck on the source files systematically. The job is currently set to be allowed to fail as it will take some time to fix all the Cppcheck detected issues. --- .gitignore | 3 +++ .gitlab-ci.yml | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1f4d9e378f..55bc4ffdd4 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ kyua.log named.memstats named.run timestamp +/compile_commands.json +/cppcheck_html/ +/cppcheck.results diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 041f10cd36..c985152e39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,8 @@ variables: BUILD_PARALLEL_JOBS: 6 TEST_PARALLEL_JOBS: 6 + MAKE: make + stages: - precheck - build @@ -22,6 +24,7 @@ stages: - system - docs - push + - postcheck ### Runner Tag Templates @@ -162,7 +165,7 @@ stages: - test -w "${CCACHE_DIR}" && export PATH="/usr/lib/ccache:${PATH}" script: - *configure - - make -j${BUILD_PARALLEL_JOBS:-1} -k all V=1 + - ${MAKE} -j${BUILD_PARALLEL_JOBS:-1} -k all V=1 - test -z "${RUN_MAKE_INSTALL}" || make install dependencies: - autoreconf:sid:amd64 @@ -221,6 +224,39 @@ stages: expire_in: "1 week" when: on_failure +.cppcheck_args: &run_cppcheck | + cppcheck --enable=warning,performance,portability,information,missingInclude \ + --include=config.h \ + --quiet \ + --std=c11 \ + --language=c \ + --project=compile_commands.json \ + --error-exitcode=2 \ + -j ${TEST_PARALLEL_JOBS:-1} \ + --xml \ + --output-file=cppcheck.results \ + --inline-suppr + +.cppcheck_report: &cppcheck_report_html | + cppcheck-htmlreport --title="BIND 9 ($CI_COMMIT_SHORT_SHA) Cppcheck Report" \ + --file=cppcheck.results \ + --report-dir=cppcheck_html/ + +.cppcheck: &cppcheck_job + <<: *default_triggering_rules + stage: postcheck + script: + - *run_cppcheck + after_script: + - *cppcheck_report_html + artifacts: + paths: + - compile_commands.json + - cppcheck.results + - cppcheck_html/ + expire_in: "1 week" + when: on_failure + ### Job Definitions # Jobs in the precheck stage @@ -437,6 +473,7 @@ gcc:sid:amd64: CFLAGS: "-Wall -Wextra -O3 -g" EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2" RUN_MAKE_INSTALL: 1 + MAKE: bear make <<: *debian_sid_amd64_image <<: *build_job @@ -454,6 +491,13 @@ unit:gcc:sid:amd64: - gcc:sid:amd64 needs: ["gcc:sid:amd64"] +cppcheck:gcc:sid:amd64: + <<: *debian_sid_amd64_image + <<: *cppcheck_job + dependencies: + - gcc:sid:amd64 + needs: ["gcc:sid:amd64"] + # Jobs for regular GCC builds on Debian Sid (i386) gcc:sid:i386: From 9ab16d10d48e4476adfa54807c62fe69cee96526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 08:46:03 +0200 Subject: [PATCH 02/30] bin/delv/delv.c: Fix invalid logic operation in REQUIRE() condition --- bin/delv/delv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 144b26c1f0..f3127ab9e8 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -529,7 +529,7 @@ setup_style(dns_master_style_t **stylep) { isc_result_t result; dns_master_style_t *style = NULL; - REQUIRE(stylep != NULL || *stylep == NULL); + REQUIRE(stylep != NULL && *stylep == NULL); styleflags |= DNS_STYLEFLAG_REL_OWNER; if (yaml) { From 9366ca769f2f6d6ede4e12fe919179f4a409a9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 08:48:06 +0200 Subject: [PATCH 03/30] bin/dig/dighost.c: Fix REQUIRE(!= NULL) condition after the variable has been dereferenced --- bin/dig/dighost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 5e24af65e5..e2018a7af7 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2045,6 +2045,9 @@ setup_lookup(dig_lookup_t *lookup) { char cookiebuf[256]; char *origin = NULL; char *textname = NULL; + + REQUIRE(lookup != NULL); + #ifdef HAVE_LIBIDN2 char idn_origin[MXNAME], idn_textname[MXNAME]; @@ -2053,7 +2056,6 @@ setup_lookup(dig_lookup_t *lookup) { check_result(result, "dns_name_settotextfilter"); #endif /* HAVE_LIBIDN2 */ - REQUIRE(lookup != NULL); INSIST(!free_now); debug("setup_lookup(%p)", lookup); From 476277a6e66086c1148d57eb1f43cf75bcd5539f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 09:19:36 +0200 Subject: [PATCH 04/30] bin/named/server.c: Fix couple of DbC conditions reported by Cppcheck --- .dir-locals.el | 2 ++ bin/named/server.c | 48 +++++++++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 3d2abc6c8f..9178b85847 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -66,6 +66,8 @@ (concat directory-of-current-dir-locals-file "bin/dig/include")) (expand-file-name (concat directory-of-current-dir-locals-file "bin/named/include")) + (expand-file-name + (concat directory-of-current-dir-locals-file "bin/named/unix/include")) (expand-file-name (concat directory-of-current-dir-locals-file "bin/rndc/include")) (expand-file-name diff --git a/bin/named/server.c b/bin/named/server.c index 4a5c7ee795..3d2bba7c9e 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -2485,15 +2485,17 @@ configure_rpz(dns_view_t *view, const cfg_obj_t **maps, } else { old = NULL; } - if (old == NULL) + if (old == NULL) { *old_rpz_okp = false; - else + } else { *old_rpz_okp = true; + } for (i = 0; zone_element != NULL; - ++i, zone_element = cfg_list_next(zone_element)) { - INSIST(old != NULL || !*old_rpz_okp); + ++i, zone_element = cfg_list_next(zone_element)) + { + INSIST(!*old_rpz_okp || old != NULL); if (*old_rpz_okp && i < old->p.num_zones) { old_zone = old->zones[i]; } else { @@ -2518,24 +2520,21 @@ configure_rpz(dns_view_t *view, const cfg_obj_t **maps, * zones are unchanged, then use the same policy data. * Data for individual zones that must be reloaded will be merged. */ - if (*old_rpz_okp && - old != NULL && memcmp(&old->p, &zones->p, sizeof(zones->p)) != 0) - { - *old_rpz_okp = false; - } - - if (*old_rpz_okp && - (old == NULL || - old->rps_cstr == NULL) != (zones->rps_cstr == NULL)) - { - *old_rpz_okp = false; - } - - if (*old_rpz_okp && - (zones->rps_cstr != NULL && - strcmp(old->rps_cstr, zones->rps_cstr) != 0)) - { - *old_rpz_okp = false; + if (*old_rpz_okp) { + if (old != NULL && + memcmp(&old->p, &zones->p, sizeof(zones->p)) != 0) + { + *old_rpz_okp = false; + } else if ((old == NULL || old->rps_cstr == NULL) != + (zones->rps_cstr == NULL)) + { + *old_rpz_okp = false; + } else if (old != NULL && + zones->rps_cstr != NULL && + strcmp(old->rps_cstr, zones->rps_cstr) != 0) + { + *old_rpz_okp = false; + } } if (*old_rpz_okp) { @@ -2549,8 +2548,9 @@ configure_rpz(dns_view_t *view, const cfg_obj_t **maps, view->rpzs->rpz_ver); } - if (pview != NULL) + if (pview != NULL) { dns_view_detach(&pview); + } return (ISC_R_SUCCESS); } @@ -6769,7 +6769,7 @@ dotat(dns_keytable_t *keytable, dns_keynode_t *keynode, void *arg) { REQUIRE(keytable != NULL); REQUIRE(keynode != NULL); - REQUIRE(arg != NULL); + REQUIRE(dotat_arg != NULL); view = dotat_arg->view; task = dotat_arg->task; From 4d2697b31c2a29b5e9027294ad9fa0940715e5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 09:38:18 +0200 Subject: [PATCH 05/30] Constify dns_name_t *signer argument to dns_acl_allowed() --- lib/dns/acl.c | 2 +- lib/dns/include/dns/acl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dns/acl.c b/lib/dns/acl.c index f7a8f87bd3..e001966645 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -592,7 +592,7 @@ dns_acl_isinsecure(const dns_acl_t *a) { * Check whether an address/signer is allowed by a given acl/aclenv. */ bool -dns_acl_allowed(isc_netaddr_t *addr, dns_name_t *signer, +dns_acl_allowed(isc_netaddr_t *addr, const dns_name_t *signer, dns_acl_t *acl, dns_aclenv_t *aclenv) { int match; diff --git a/lib/dns/include/dns/acl.h b/lib/dns/include/dns/acl.h index 92bf20e181..07082d4891 100644 --- a/lib/dns/include/dns/acl.h +++ b/lib/dns/include/dns/acl.h @@ -182,7 +182,7 @@ dns_acl_isinsecure(const dns_acl_t *a); */ bool -dns_acl_allowed(isc_netaddr_t *addr, dns_name_t *signer, +dns_acl_allowed(isc_netaddr_t *addr, const dns_name_t *signer, dns_acl_t *acl, dns_aclenv_t *aclenv); /*%< * Return #true iff the 'addr', 'signer', or ECS values are From 2e304b0b7f5f08d01572cc855deadb1026e15ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 09:39:02 +0200 Subject: [PATCH 06/30] Change dns_tsigkey_identity from macro to a function and const argument and result --- lib/dns/include/dns/tsig.h | 18 +++++++++++++----- lib/dns/tsig.c | 14 ++++++++++++++ lib/dns/win32/libdns.def.in | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/dns/include/dns/tsig.h b/lib/dns/include/dns/tsig.h index 1aeaa3461b..c4d4f2f0a8 100644 --- a/lib/dns/include/dns/tsig.h +++ b/lib/dns/include/dns/tsig.h @@ -86,13 +86,21 @@ struct dns_tsigkey { ISC_LINK(dns_tsigkey_t) link; }; -#define dns_tsigkey_identity(tsigkey) \ - ((tsigkey) == NULL ? NULL : \ - (tsigkey)->generated ? ((tsigkey)->creator) : \ - (&((tsigkey)->name))) - ISC_LANG_BEGINDECLS +const dns_name_t * +dns_tsigkey_identity(const dns_tsigkey_t *tsigkey); +/*%< + * Returns the identity of the provided TSIG key. + * + * Requires: + *\li 'tsigkey' is a valid TSIG key or NULL + * + * Returns: + *\li NULL if 'tsigkey' was NULL + *\li identity of the provided TSIG key + */ + isc_result_t dns_tsigkey_create(const dns_name_t *name, const dns_name_t *algorithm, unsigned char *secret, int length, bool generated, diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index a350178648..fd5f61d063 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -643,6 +643,20 @@ dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp) { return (result); } +const dns_name_t * +dns_tsigkey_identity(const dns_tsigkey_t *tsigkey) { + REQUIRE(tsigkey == NULL || VALID_TSIG_KEY(tsigkey)); + + if (tsigkey == NULL) { + return (NULL); + } + if (tsigkey->generated) { + return (tsigkey->creator); + } else { + return (&tsigkey->name); + } +} + isc_result_t dns_tsigkey_create(const dns_name_t *name, const dns_name_t *algorithm, unsigned char *secret, int length, bool generated, diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 44092edcef..a3c7a90af5 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -1021,6 +1021,7 @@ dns_tsigkey_create dns_tsigkey_createfromkey dns_tsigkey_detach dns_tsigkey_find +dns_tsigkey_identity dns_tsigkey_setdeleted dns_tsigkeyring_add dns_tsigkeyring_attach From 43925b2a8b1b17d1cbf7940f9ffa347889e181e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 09:39:35 +0200 Subject: [PATCH 07/30] bin/named/zoneconf.c: Reset dns_name_t *tsig on every view iteration --- bin/named/zoneconf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index b9c1375249..aebea7aa1a 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -758,7 +758,6 @@ isself(dns_view_t *myview, dns_tsigkey_t *mykey, dns_aclenv_t *env = ns_interfacemgr_getaclenv(interfacemgr); dns_view_t *view; dns_tsigkey_t *key = NULL; - dns_name_t *tsig = NULL; isc_netaddr_t netsrc; isc_netaddr_t netdst; @@ -773,7 +772,9 @@ isself(dns_view_t *myview, dns_tsigkey_t *mykey, for (view = ISC_LIST_HEAD(named_g_server->viewlist); view != NULL; - view = ISC_LIST_NEXT(view, link)) { + view = ISC_LIST_NEXT(view, link)) + { + const dns_name_t *tsig = NULL; if (view->matchrecursiveonly) continue; From fa7475b77a27d326be15a4c4b987f1f5388272dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 09:49:31 +0200 Subject: [PATCH 08/30] Fix the constification of the dns_name_t * result variable for dns_tsig_identity() --- bin/named/server.c | 2 +- lib/dns/message.c | 2 +- lib/dns/tkey.c | 2 +- lib/dns/zone.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 3d2bba7c9e..ea505135f5 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -9558,7 +9558,7 @@ get_matching_view(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr, if (message->rdclass == view->rdclass || message->rdclass == dns_rdataclass_any) { - dns_name_t *tsig = NULL; + const dns_name_t *tsig = NULL; *sigresult = dns_message_rechecksig(message, view); if (*sigresult == ISC_R_SUCCESS) { diff --git a/lib/dns/message.c b/lib/dns/message.c index 3dac389011..4c767cdbb5 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -3056,7 +3056,7 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) { dns_name_clone(&sig.signer, signer); dns_rdata_freestruct(&sig); } else { - dns_name_t *identity; + const dns_name_t *identity; dns_rdata_any_tsig_t tsig; result = dns_rdataset_first(msg->tsig); diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index c9136f738b..33584d3aa9 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -645,7 +645,7 @@ process_deletetkey(dns_name_t *signer, dns_name_t *name, { isc_result_t result; dns_tsigkey_t *tsigkey = NULL; - dns_name_t *identity; + const dns_name_t *identity; result = dns_tsigkey_find(&tsigkey, name, &tkeyin->algorithm, ring); if (result != ISC_R_SUCCESS) { diff --git a/lib/dns/zone.c b/lib/dns/zone.c index a9d2e2888b..d8e2c64384 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -13665,7 +13665,7 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from, uint32_t serial = 0; bool have_serial = false; dns_tsigkey_t *tsigkey; - dns_name_t *tsig; + const dns_name_t *tsig; REQUIRE(DNS_ZONE_VALID(zone)); From 91cc6b9eb9242da5eb188462725b3553fd372360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 09:55:19 +0200 Subject: [PATCH 09/30] lib/dns/ecdb.c: Fix couple of DbC conditions reported by Cppcheck --- lib/dns/ecdb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/dns/ecdb.c b/lib/dns/ecdb.c index 1f4b3adc95..6a5a2c90d2 100644 --- a/lib/dns/ecdb.c +++ b/lib/dns/ecdb.c @@ -760,28 +760,30 @@ rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp) { static isc_result_t rdatasetiter_first(dns_rdatasetiter_t *iterator) { + REQUIRE(DNS_RDATASETITER_VALID(iterator)); + ecdb_rdatasetiter_t *ecdbiterator = (ecdb_rdatasetiter_t *)iterator; dns_ecdbnode_t *ecdbnode = (dns_ecdbnode_t *)iterator->node; - REQUIRE(DNS_RDATASETITER_VALID(iterator)); - - if (ISC_LIST_EMPTY(ecdbnode->rdatasets)) + if (ISC_LIST_EMPTY(ecdbnode->rdatasets)) { return (ISC_R_NOMORE); + } ecdbiterator->current = ISC_LIST_HEAD(ecdbnode->rdatasets); return (ISC_R_SUCCESS); } static isc_result_t rdatasetiter_next(dns_rdatasetiter_t *iterator) { - ecdb_rdatasetiter_t *ecdbiterator = (ecdb_rdatasetiter_t *)iterator; - REQUIRE(DNS_RDATASETITER_VALID(iterator)); + ecdb_rdatasetiter_t *ecdbiterator = (ecdb_rdatasetiter_t *)iterator; + ecdbiterator->current = ISC_LIST_NEXT(ecdbiterator->current, link); - if (ecdbiterator->current == NULL) + if (ecdbiterator->current == NULL) { return (ISC_R_NOMORE); - else + } else { return (ISC_R_SUCCESS); + } } static void From d8879af877c232bd15d0011e65c8759f36a09901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 10:00:46 +0200 Subject: [PATCH 10/30] Fix passing NULL after the last typed argument to a variadic function leads to undefined behaviour. From Cppcheck: Passing NULL after the last typed argument to a variadic function leads to undefined behaviour. The C99 standard, in section 7.15.1.1, states that if the type used by va_arg() is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined. The value of the NULL macro is an implementation-defined null pointer constant (7.17), which can be any integer constant expression with the value 0, or such an expression casted to (void*) (6.3.2.3). This includes values like 0, 0L, or even 0LL.In practice on common architectures, this will cause real crashes if sizeof(int) != sizeof(void*), and NULL is defined to 0 or any other null pointer constant that promotes to int. To reproduce you might be able to use this little code example on 64bit platforms. If the output includes "ERROR", the sentinel had only 4 out of 8 bytes initialized to zero and was not detected as the final argument to stop argument processing via va_arg(). Changing the 0 to (void*)0 or 0L will make the "ERROR" output go away. void f(char *s, ...) { va_list ap; va_start(ap,s); for (;;) { char *p = va_arg(ap,char*); printf("%018p, %s\n", p, (long)p & 255 ? p : ""); if(!p) break; } va_end(ap); } void g() { char *s2 = "x"; char *s3 = "ERROR"; // changing 0 to 0L for the 7th argument (which is intended to act as // sentinel) makes the error go away on x86_64 f("first", s2, s2, s2, s2, s2, 0, s3, (char*)0); } void h() { int i; volatile unsigned char a[1000]; for (i = 0; ientry, &value, - "country", "iso_code", NULL); + "country", "iso_code", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -356,7 +356,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_country_name: case dns_geoip_city_countryname: ret = MMDB_get_value(&state->entry, &value, - "country", "names", "en", NULL); + "country", "names", "en", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -365,7 +365,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_country_continentcode: case dns_geoip_city_continentcode: ret = MMDB_get_value(&state->entry, &value, - "continent", "code", NULL); + "continent", "code", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -374,7 +374,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_country_continent: case dns_geoip_city_continent: ret = MMDB_get_value(&state->entry, &value, - "continent", "names", "en", NULL); + "continent", "names", "en", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -383,7 +383,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_region: case dns_geoip_city_region: ret = MMDB_get_value(&state->entry, &value, - "subdivisions", "0", "iso_code", NULL); + "subdivisions", "0", "iso_code", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -392,7 +392,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_regionname: case dns_geoip_city_regionname: ret = MMDB_get_value(&state->entry, &value, - "subdivisions", "0", "names", "en", NULL); + "subdivisions", "0", "names", "en", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -400,7 +400,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_city_name: ret = MMDB_get_value(&state->entry, &value, - "city", "names", "en", NULL); + "city", "names", "en", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -408,7 +408,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_city_postalcode: ret = MMDB_get_value(&state->entry, &value, - "postal", "code", NULL); + "postal", "code", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -416,7 +416,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_city_timezonecode: ret = MMDB_get_value(&state->entry, &value, - "location", "time_zone", NULL); + "location", "time_zone", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -425,14 +425,14 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_city_metrocode: ret = MMDB_get_value(&state->entry, &value, - "location", "metro_code", NULL); + "location", "metro_code", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } break; case dns_geoip_isp_name: - ret = MMDB_get_value(&state->entry, &value, "isp", NULL); + ret = MMDB_get_value(&state->entry, &value, "isp", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } @@ -442,8 +442,9 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, INSIST(elt->as_string != NULL); ret = MMDB_get_value(&state->entry, &value, - "autonomous_system_number", NULL); + "autonomous_system_number", (char *)0); if (ret == MMDB_SUCCESS) { + int i; s = elt->as_string; if (strncasecmp(s, "AS", 2) == 0) { s += 2; @@ -455,14 +456,14 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, case dns_geoip_org_name: ret = MMDB_get_value(&state->entry, &value, - "autonomous_system_organization", NULL); + "autonomous_system_organization", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } break; case dns_geoip_domain_name: - ret = MMDB_get_value(&state->entry, &value, "domain", NULL); + ret = MMDB_get_value(&state->entry, &value, "domain", (char *)0); if (ret == MMDB_SUCCESS) { return (match_string(&value, elt->as_string)); } From cea871464fe56b951dfde5a33dda962551c919b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 10:04:26 +0200 Subject: [PATCH 11/30] lib/dns/gssapi_link.c: Fix %d -> %u formatting when printing unsigned integers --- lib/dns/gssapi_link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dns/gssapi_link.c b/lib/dns/gssapi_link.c index 8cbf5771ae..e9bbf4d05c 100644 --- a/lib/dns/gssapi_link.c +++ b/lib/dns/gssapi_link.c @@ -312,7 +312,7 @@ gssapi_dump(dst_key_t *key, isc_mem_t *mctx, char **buffer, int *length) { major = gss_export_sec_context(&minor, &key->keydata.gssctx, &gssbuffer); if (major != GSS_S_COMPLETE) { - fprintf(stderr, "gss_export_sec_context -> %d, %d\n", + fprintf(stderr, "gss_export_sec_context -> %u, %u\n", major, minor); return (ISC_R_FAILURE); } From 0f5860aad3a131d22b6fb1ffc97da83a1b1bca21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 10:05:27 +0200 Subject: [PATCH 12/30] lib/dns/name.c: Fix dereference before DbC check reported by Cppcheck --- lib/dns/name.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dns/name.c b/lib/dns/name.c index 2c021aad1f..e751194478 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1345,7 +1345,7 @@ dns_name_totext2(const dns_name_t *name, unsigned int options, unsigned int trem, count; unsigned int labels; bool saw_root = false; - unsigned int oused = target->used; + unsigned int oused; dns_name_totextfilter_t *mem; dns_name_totextfilter_t totext_filter_proc = NULL; isc_result_t result; @@ -1358,6 +1358,8 @@ dns_name_totext2(const dns_name_t *name, unsigned int options, REQUIRE(VALID_NAME(name)); REQUIRE(ISC_BUFFER_VALID(target)); + oused = target->used; + result = totext_filter_proc_key_init(); if (result != ISC_R_SUCCESS) return (result); From 8be5c3fcfcbe7ed2dee3eaf508d0a674141636fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 10:28:30 +0200 Subject: [PATCH 13/30] lib/dns/rbt.c: Suppress nullPointerRedundantCheck warnings from Cppcheck --- lib/dns/rbt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index ce8e1f3436..34170ce9ab 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -2676,6 +2676,7 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) { * Fix color violations. */ if (IS_BLACK(item)) { + /* cppcheck-suppress nullPointerRedundantCheck symbolName=item */ parent = PARENT(item); while (child != *rootp && IS_BLACK(child)) { @@ -2693,6 +2694,7 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) { INSIST(sibling != NULL); + /* cppcheck-suppress nullPointerRedundantCheck symbolName=sibling */ if (IS_BLACK(LEFT(sibling)) && IS_BLACK(RIGHT(sibling))) { MAKE_RED(sibling); @@ -2732,6 +2734,7 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) { INSIST(sibling != NULL); + /* cppcheck-suppress nullPointerRedundantCheck symbolName=sibling */ if (IS_BLACK(LEFT(sibling)) && IS_BLACK(RIGHT(sibling))) { MAKE_RED(sibling); @@ -2863,6 +2866,7 @@ check_properties_helper(dns_rbtnode_t *node) { return (false); } + /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if ((DOWN(node) != NULL) && (!IS_ROOT(DOWN(node)))) return (false); @@ -2900,12 +2904,15 @@ check_black_distance_helper(dns_rbtnode_t *node, size_t *distance) { return (true); } + /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if (!check_black_distance_helper(LEFT(node), &dl)) return (false); + /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if (!check_black_distance_helper(RIGHT(node), &dr)) return (false); + /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if (!check_black_distance_helper(DOWN(node), &dd)) return (false); From d508ce4036ce4431b8e6a58697cf890bed6db341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 10:35:49 +0200 Subject: [PATCH 14/30] lib/dns/rbtdb.c: Add DbC check to safely dereference rbtdb in rbt_datafixer() --- lib/dns/rbtdb.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index cef118c5ce..26d0f1a41e 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -7081,17 +7081,14 @@ rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize, dns_rbtdb_t *rbtdb = (dns_rbtdb_t *) arg; rdatasetheader_t *header; unsigned char *limit = ((unsigned char *) base) + filesize; - unsigned char *p; - size_t size; - unsigned int count; REQUIRE(rbtnode != NULL); + REQUIRE(VALID_RBTDB(rbtdb)); for (header = rbtnode->data; header != NULL; header = header->next) { - p = (unsigned char *) header; - - size = dns_rdataslab_size(p, sizeof(*header)); - count = dns_rdataslab_count(p, sizeof(*header));; + unsigned char *p = (unsigned char *) header; + size_t size = dns_rdataslab_size(p, sizeof(*header)); + unsigned int count = dns_rdataslab_count(p, sizeof(*header));; rbtdb->current_version->records += count; rbtdb->current_version->bytes += size; isc_crc64_update(crc, p, size); @@ -7105,7 +7102,7 @@ rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize, header->node = rbtnode; header->node_is_relative = 0; - if (rbtdb != NULL && RESIGN(header) && + if (RESIGN(header) && (header->resign != 0 || header->resign_lsb != 0)) { int idx = header->node->locknum; From e68333aa67e304ff295820cadb7bbfb293e77111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 10:38:18 +0200 Subject: [PATCH 15/30] lib/dns/rdata.c: Silence false positive nullPointerRedundantCheck warning from Cppcheck --- lib/dns/rdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index bbbc33e8a9..6f4d544a9b 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -1199,7 +1199,7 @@ dns_rdata_tostruct(const dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { void dns_rdata_freestruct(void *source) { dns_rdatacommon_t *common = source; - REQUIRE(source != NULL); + REQUIRE(common != NULL); FREESTRUCTSWITCH } From 66af8713d8a4350780c060d517dea27d2c31dd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 10:40:51 +0200 Subject: [PATCH 16/30] lib/dns/rdata/*/*.c: Silence false positive nullPointerRedundantCheck warning from Cppcheck Cppcheck gets confused by: void bar(void *arg) { foo *data = arg; REQUIRE(source != NULL); REQUIRE(data->member != NULL); } and for consistency the DbC check needs to be changed to void bar(void *arg) { foo *data = arg; REQUIRE(data != NULL); REQUIRE(data->member != NULL); } --- lib/dns/rdata/any_255/tsig_250.c | 4 ++-- lib/dns/rdata/ch_3/a_1.c | 4 ++-- lib/dns/rdata/generic/afsdb_18.c | 6 +++--- lib/dns/rdata/generic/amtrelay_260.c | 6 +++--- lib/dns/rdata/generic/avc_258.c | 8 ++++---- lib/dns/rdata/generic/caa_257.c | 6 +++--- lib/dns/rdata/generic/cds_59.c | 18 ++++++++++-------- lib/dns/rdata/generic/cert_37.c | 4 ++-- lib/dns/rdata/generic/cname_5.c | 6 +++--- lib/dns/rdata/generic/csync_62.c | 6 +++--- lib/dns/rdata/generic/dlv_32769.c | 1 + lib/dns/rdata/generic/dname_39.c | 6 +++--- lib/dns/rdata/generic/doa_259.c | 5 +++-- lib/dns/rdata/generic/ds_43.c | 6 +++--- lib/dns/rdata/generic/eui48_108.c | 6 +++--- lib/dns/rdata/generic/eui64_109.c | 6 +++--- lib/dns/rdata/generic/gpos_27.c | 6 +++--- lib/dns/rdata/generic/hinfo_13.c | 6 +++--- lib/dns/rdata/generic/hip_55.c | 6 +++--- lib/dns/rdata/generic/ipseckey_45.c | 6 +++--- lib/dns/rdata/generic/isdn_20.c | 6 +++--- lib/dns/rdata/generic/key_25.c | 2 +- lib/dns/rdata/generic/keydata_65533.c | 6 +++--- lib/dns/rdata/generic/l32_105.c | 6 +++--- lib/dns/rdata/generic/l64_106.c | 6 +++--- lib/dns/rdata/generic/loc_29.c | 6 +++--- lib/dns/rdata/generic/lp_107.c | 6 +++--- lib/dns/rdata/generic/mb_7.c | 6 +++--- lib/dns/rdata/generic/md_3.c | 6 +++--- lib/dns/rdata/generic/mf_4.c | 6 +++--- lib/dns/rdata/generic/mg_8.c | 6 +++--- lib/dns/rdata/generic/minfo_14.c | 6 +++--- lib/dns/rdata/generic/mr_9.c | 6 +++--- lib/dns/rdata/generic/mx_15.c | 6 +++--- lib/dns/rdata/generic/naptr_35.c | 6 +++--- lib/dns/rdata/generic/nid_104.c | 6 +++--- lib/dns/rdata/generic/ninfo_56.c | 11 ++++++----- lib/dns/rdata/generic/ns_2.c | 6 +++--- lib/dns/rdata/generic/nsec3_50.c | 6 +++--- lib/dns/rdata/generic/nsec3param_51.c | 6 +++--- lib/dns/rdata/generic/nsec_47.c | 6 +++--- lib/dns/rdata/generic/null_10.c | 6 +++--- lib/dns/rdata/generic/nxt_30.c | 6 +++--- lib/dns/rdata/generic/openpgpkey_61.c | 6 +++--- lib/dns/rdata/generic/opt_41.c | 6 +++--- lib/dns/rdata/generic/proforma.c | 4 ++-- lib/dns/rdata/generic/ptr_12.c | 6 +++--- lib/dns/rdata/generic/rp_17.c | 6 +++--- lib/dns/rdata/generic/rrsig_46.c | 6 +++--- lib/dns/rdata/generic/rt_21.c | 6 +++--- lib/dns/rdata/generic/sig_24.c | 6 +++--- lib/dns/rdata/generic/sink_40.c | 6 +++--- lib/dns/rdata/generic/smimea_53.c | 5 +++-- lib/dns/rdata/generic/soa_6.c | 6 +++--- lib/dns/rdata/generic/spf_99.c | 9 +++++---- lib/dns/rdata/generic/sshfp_44.c | 4 ++-- lib/dns/rdata/generic/ta_32768.c | 1 + lib/dns/rdata/generic/talink_58.c | 6 +++--- lib/dns/rdata/generic/tkey_249.c | 6 +++--- lib/dns/rdata/generic/tlsa_52.c | 8 ++++---- lib/dns/rdata/generic/txt_16.c | 10 +++++----- lib/dns/rdata/generic/uri_256.c | 6 +++--- lib/dns/rdata/generic/x25_19.c | 7 ++++--- lib/dns/rdata/generic/zonemd_63.c | 4 ++-- lib/dns/rdata/hs_4/a_1.c | 3 ++- lib/dns/rdata/in_1/a6_38.c | 6 +++--- lib/dns/rdata/in_1/a_1.c | 5 +++-- lib/dns/rdata/in_1/aaaa_28.c | 6 +++--- lib/dns/rdata/in_1/apl_42.c | 5 +++-- lib/dns/rdata/in_1/atma_34.c | 6 +++--- lib/dns/rdata/in_1/dhcid_49.c | 4 ++-- lib/dns/rdata/in_1/eid_31.c | 6 +++--- lib/dns/rdata/in_1/kx_36.c | 6 +++--- lib/dns/rdata/in_1/nimloc_32.c | 6 +++--- lib/dns/rdata/in_1/nsap-ptr_23.c | 6 +++--- lib/dns/rdata/in_1/nsap_22.c | 6 +++--- lib/dns/rdata/in_1/px_26.c | 6 +++--- lib/dns/rdata/in_1/srv_33.c | 6 +++--- lib/dns/rdata/in_1/wks_11.c | 5 +++-- 79 files changed, 240 insertions(+), 227 deletions(-) diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index 5ed242d468..3337ad08dc 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -358,7 +358,7 @@ fromstruct_any_tsig(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_tsig); REQUIRE(rdclass == dns_rdataclass_any); - REQUIRE(source != NULL); + REQUIRE(tsig != NULL); REQUIRE(tsig->common.rdclass == rdclass); REQUIRE(tsig->common.rdtype == type); @@ -523,7 +523,7 @@ static inline void freestruct_any_tsig(ARGS_FREESTRUCT) { dns_rdata_any_tsig_t *tsig = (dns_rdata_any_tsig_t *) source; - REQUIRE(source != NULL); + REQUIRE(tsig != NULL); REQUIRE(tsig->common.rdtype == dns_rdatatype_tsig); REQUIRE(tsig->common.rdclass == dns_rdataclass_any); diff --git a/lib/dns/rdata/ch_3/a_1.c b/lib/dns/rdata/ch_3/a_1.c index 94cae92c3c..be1b489ef4 100644 --- a/lib/dns/rdata/ch_3/a_1.c +++ b/lib/dns/rdata/ch_3/a_1.c @@ -191,7 +191,7 @@ fromstruct_ch_a(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_a); - REQUIRE(source != NULL); + REQUIRE(a != NULL); REQUIRE(a->common.rdtype == type); REQUIRE(a->common.rdclass == rdclass); @@ -235,7 +235,7 @@ static inline void freestruct_ch_a(ARGS_FREESTRUCT) { dns_rdata_ch_a_t *a = source; - REQUIRE(source != NULL); + REQUIRE(a != NULL); REQUIRE(a->common.rdtype == dns_rdatatype_a); if (a->mctx == NULL) diff --git a/lib/dns/rdata/generic/afsdb_18.c b/lib/dns/rdata/generic/afsdb_18.c index 812dfa6e45..2c924b9f8d 100644 --- a/lib/dns/rdata/generic/afsdb_18.c +++ b/lib/dns/rdata/generic/afsdb_18.c @@ -174,7 +174,7 @@ fromstruct_afsdb(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_afsdb); - REQUIRE(source != NULL); + REQUIRE(afsdb != NULL); REQUIRE(afsdb->common.rdclass == rdclass); REQUIRE(afsdb->common.rdtype == type); @@ -193,7 +193,7 @@ tostruct_afsdb(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_afsdb); - REQUIRE(target != NULL); + REQUIRE(afsdb != NULL); REQUIRE(rdata->length != 0); afsdb->common.rdclass = rdata->rdclass; @@ -219,7 +219,7 @@ static inline void freestruct_afsdb(ARGS_FREESTRUCT) { dns_rdata_afsdb_t *afsdb = source; - REQUIRE(source != NULL); + REQUIRE(afsdb != NULL); REQUIRE(afsdb->common.rdtype == dns_rdatatype_afsdb); if (afsdb->mctx == NULL) diff --git a/lib/dns/rdata/generic/amtrelay_260.c b/lib/dns/rdata/generic/amtrelay_260.c index bb4a38419c..ca266383a3 100644 --- a/lib/dns/rdata/generic/amtrelay_260.c +++ b/lib/dns/rdata/generic/amtrelay_260.c @@ -269,7 +269,7 @@ fromstruct_amtrelay(ARGS_FROMSTRUCT) { uint32_t n; REQUIRE(type == dns_rdatatype_amtrelay); - REQUIRE(source != NULL); + REQUIRE(amtrelay != NULL); REQUIRE(amtrelay->common.rdtype == type); REQUIRE(amtrelay->common.rdclass == rdclass); @@ -310,7 +310,7 @@ tostruct_amtrelay(ARGS_TOSTRUCT) { uint32_t n; REQUIRE(rdata->type == dns_rdatatype_amtrelay); - REQUIRE(target != NULL); + REQUIRE(amtrelay != NULL); REQUIRE(rdata->length >= 2); amtrelay->common.rdclass = rdata->rdclass; @@ -370,7 +370,7 @@ static inline void freestruct_amtrelay(ARGS_FREESTRUCT) { dns_rdata_amtrelay_t *amtrelay = source; - REQUIRE(source != NULL); + REQUIRE(amtrelay != NULL); REQUIRE(amtrelay->common.rdtype == dns_rdatatype_amtrelay); if (amtrelay->mctx == NULL) diff --git a/lib/dns/rdata/generic/avc_258.c b/lib/dns/rdata/generic/avc_258.c index 31bbaffdc0..e8efa377d7 100644 --- a/lib/dns/rdata/generic/avc_258.c +++ b/lib/dns/rdata/generic/avc_258.c @@ -90,7 +90,7 @@ tostruct_avc(ARGS_TOSTRUCT) { dns_rdata_avc_t *avc = target; REQUIRE(rdata->type == dns_rdatatype_avc); - REQUIRE(target != NULL); + REQUIRE(avc != NULL); avc->common.rdclass = rdata->rdclass; avc->common.rdtype = rdata->type; @@ -101,10 +101,10 @@ tostruct_avc(ARGS_TOSTRUCT) { static inline void freestruct_avc(ARGS_FREESTRUCT) { - dns_rdata_avc_t *txt = source; + dns_rdata_avc_t *avc = source; - REQUIRE(source != NULL); - REQUIRE(txt->common.rdtype == dns_rdatatype_avc); + REQUIRE(avc != NULL); + REQUIRE(avc->common.rdtype == dns_rdatatype_avc); generic_freestruct_txt(source); } diff --git a/lib/dns/rdata/generic/caa_257.c b/lib/dns/rdata/generic/caa_257.c index 4dc3639906..8dd75c04dd 100644 --- a/lib/dns/rdata/generic/caa_257.c +++ b/lib/dns/rdata/generic/caa_257.c @@ -196,7 +196,7 @@ fromstruct_caa(ARGS_FROMSTRUCT) { unsigned int i; REQUIRE(type == dns_rdatatype_caa); - REQUIRE(source != NULL); + REQUIRE(caa != NULL); REQUIRE(caa->common.rdtype == type); REQUIRE(caa->common.rdclass == rdclass); REQUIRE(caa->tag != NULL && caa->tag_len != 0); @@ -239,7 +239,7 @@ tostruct_caa(ARGS_TOSTRUCT) { isc_region_t sr; REQUIRE(rdata->type == dns_rdatatype_caa); - REQUIRE(target != NULL); + REQUIRE(caa != NULL); REQUIRE(rdata->length >= 3U); REQUIRE(rdata->data != NULL); @@ -291,7 +291,7 @@ static inline void freestruct_caa(ARGS_FREESTRUCT) { dns_rdata_caa_t *caa = (dns_rdata_caa_t *) source; - REQUIRE(source != NULL); + REQUIRE(caa != NULL); REQUIRE(caa->common.rdtype == dns_rdatatype_caa); if (caa->mctx == NULL) diff --git a/lib/dns/rdata/generic/cds_59.c b/lib/dns/rdata/generic/cds_59.c index f94c6a6a3f..1dace20458 100644 --- a/lib/dns/rdata/generic/cds_59.c +++ b/lib/dns/rdata/generic/cds_59.c @@ -86,7 +86,7 @@ tostruct_cds(ARGS_TOSTRUCT) { dns_rdata_cds_t *cds = target; REQUIRE(rdata->type == dns_rdatatype_cds); - REQUIRE(target != NULL); + REQUIRE(cds != NULL); REQUIRE(rdata->length != 0); /* @@ -101,17 +101,19 @@ tostruct_cds(ARGS_TOSTRUCT) { static inline void freestruct_cds(ARGS_FREESTRUCT) { - dns_rdata_cds_t *ds = source; + dns_rdata_cds_t *cds = source; - REQUIRE(ds != NULL); - REQUIRE(ds->common.rdtype == dns_rdatatype_cds); + REQUIRE(cds != NULL); + REQUIRE(cds->common.rdtype == dns_rdatatype_cds); - if (ds->mctx == NULL) + if (cds->mctx == NULL) { return; + } - if (ds->digest != NULL) - isc_mem_free(ds->mctx, ds->digest); - ds->mctx = NULL; + if (cds->digest != NULL) { + isc_mem_free(cds->mctx, cds->digest); + } + cds->mctx = NULL; } static inline isc_result_t diff --git a/lib/dns/rdata/generic/cert_37.c b/lib/dns/rdata/generic/cert_37.c index a0ac769153..4b29cabdea 100644 --- a/lib/dns/rdata/generic/cert_37.c +++ b/lib/dns/rdata/generic/cert_37.c @@ -162,7 +162,7 @@ fromstruct_cert(ARGS_FROMSTRUCT) { dns_rdata_cert_t *cert = source; REQUIRE(type == dns_rdatatype_cert); - REQUIRE(source != NULL); + REQUIRE(cert != NULL); REQUIRE(cert->common.rdtype == type); REQUIRE(cert->common.rdclass == rdclass); @@ -182,7 +182,7 @@ tostruct_cert(ARGS_TOSTRUCT) { isc_region_t region; REQUIRE(rdata->type == dns_rdatatype_cert); - REQUIRE(target != NULL); + REQUIRE(cert != NULL); REQUIRE(rdata->length != 0); cert->common.rdclass = rdata->rdclass; diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c index 3da82ebee4..1c40bcd6da 100644 --- a/lib/dns/rdata/generic/cname_5.c +++ b/lib/dns/rdata/generic/cname_5.c @@ -123,7 +123,7 @@ fromstruct_cname(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_cname); - REQUIRE(source != NULL); + REQUIRE(cname != NULL); REQUIRE(cname->common.rdtype == type); REQUIRE(cname->common.rdclass == rdclass); @@ -141,7 +141,7 @@ tostruct_cname(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_cname); - REQUIRE(target != NULL); + REQUIRE(cname != NULL); REQUIRE(rdata->length != 0); cname->common.rdclass = rdata->rdclass; @@ -161,7 +161,7 @@ static inline void freestruct_cname(ARGS_FREESTRUCT) { dns_rdata_cname_t *cname = source; - REQUIRE(source != NULL); + REQUIRE(cname != NULL); if (cname->mctx == NULL) return; diff --git a/lib/dns/rdata/generic/csync_62.c b/lib/dns/rdata/generic/csync_62.c index c63912875d..481916d3d6 100644 --- a/lib/dns/rdata/generic/csync_62.c +++ b/lib/dns/rdata/generic/csync_62.c @@ -140,7 +140,7 @@ fromstruct_csync(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_csync); - REQUIRE(source != NULL); + REQUIRE(csync != NULL); REQUIRE(csync->common.rdtype == type); REQUIRE(csync->common.rdclass == rdclass); REQUIRE(csync->typebits != NULL || csync->len == 0); @@ -163,7 +163,7 @@ tostruct_csync(ARGS_TOSTRUCT) { dns_rdata_csync_t *csync = target; REQUIRE(rdata->type == dns_rdatatype_csync); - REQUIRE(target != NULL); + REQUIRE(csync != NULL); REQUIRE(rdata->length != 0); csync->common.rdclass = rdata->rdclass; @@ -194,7 +194,7 @@ static inline void freestruct_csync(ARGS_FREESTRUCT) { dns_rdata_csync_t *csync = source; - REQUIRE(source != NULL); + REQUIRE(csync != NULL); REQUIRE(csync->common.rdtype == dns_rdatatype_csync); if (csync->mctx == NULL) diff --git a/lib/dns/rdata/generic/dlv_32769.c b/lib/dns/rdata/generic/dlv_32769.c index d61206aa8c..358802327b 100644 --- a/lib/dns/rdata/generic/dlv_32769.c +++ b/lib/dns/rdata/generic/dlv_32769.c @@ -87,6 +87,7 @@ tostruct_dlv(ARGS_TOSTRUCT) { dns_rdata_dlv_t *dlv = target; REQUIRE(rdata->type == dns_rdatatype_dlv); + REQUIRE(dlv != NULL); dlv->common.rdclass = rdata->rdclass; dlv->common.rdtype = rdata->type; diff --git a/lib/dns/rdata/generic/dname_39.c b/lib/dns/rdata/generic/dname_39.c index 50c5838564..cebd8c7e46 100644 --- a/lib/dns/rdata/generic/dname_39.c +++ b/lib/dns/rdata/generic/dname_39.c @@ -123,7 +123,7 @@ fromstruct_dname(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_dname); - REQUIRE(source != NULL); + REQUIRE(dname != NULL); REQUIRE(dname->common.rdtype == type); REQUIRE(dname->common.rdclass == rdclass); @@ -141,7 +141,7 @@ tostruct_dname(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_dname); - REQUIRE(target != NULL); + REQUIRE(dname != NULL); REQUIRE(rdata->length != 0); dname->common.rdclass = rdata->rdclass; @@ -161,7 +161,7 @@ static inline void freestruct_dname(ARGS_FREESTRUCT) { dns_rdata_dname_t *dname = source; - REQUIRE(source != NULL); + REQUIRE(dname != NULL); REQUIRE(dname->common.rdtype == dns_rdatatype_dname); if (dname->mctx == NULL) diff --git a/lib/dns/rdata/generic/doa_259.c b/lib/dns/rdata/generic/doa_259.c index 16c0703d63..8597e5a564 100644 --- a/lib/dns/rdata/generic/doa_259.c +++ b/lib/dns/rdata/generic/doa_259.c @@ -191,7 +191,7 @@ fromstruct_doa(ARGS_FROMSTRUCT) { dns_rdata_doa_t *doa = source; REQUIRE(type == dns_rdatatype_doa); - REQUIRE(source != NULL); + REQUIRE(doa != NULL); REQUIRE(doa->common.rdtype == dns_rdatatype_doa); REQUIRE(doa->common.rdclass == rdclass); @@ -210,6 +210,7 @@ tostruct_doa(ARGS_TOSTRUCT) { REQUIRE(rdata != NULL); REQUIRE(rdata->type == dns_rdatatype_doa); + REQUIRE(doa != NULL); REQUIRE(rdata->length != 0); doa->common.rdclass = rdata->rdclass; @@ -288,7 +289,7 @@ static inline void freestruct_doa(ARGS_FREESTRUCT) { dns_rdata_doa_t *doa = source; - REQUIRE(source != NULL); + REQUIRE(doa != NULL); REQUIRE(doa->common.rdtype == dns_rdatatype_doa); if (doa->mctx == NULL) { diff --git a/lib/dns/rdata/generic/ds_43.c b/lib/dns/rdata/generic/ds_43.c index 8312351b26..c55fe10846 100644 --- a/lib/dns/rdata/generic/ds_43.c +++ b/lib/dns/rdata/generic/ds_43.c @@ -233,7 +233,7 @@ static inline isc_result_t generic_fromstruct_ds(ARGS_FROMSTRUCT) { dns_rdata_ds_t *ds = source; - REQUIRE(source != NULL); + REQUIRE(ds != NULL); REQUIRE(ds->common.rdtype == type); REQUIRE(ds->common.rdclass == rdclass); @@ -272,7 +272,7 @@ generic_tostruct_ds(ARGS_TOSTRUCT) { dns_rdata_ds_t *ds = target; isc_region_t region; - REQUIRE(target != NULL); + REQUIRE(ds != NULL); REQUIRE(rdata->length != 0); REQUIRE(ds->common.rdtype == rdata->type); REQUIRE(ds->common.rdclass == rdata->rdclass); @@ -301,7 +301,7 @@ tostruct_ds(ARGS_TOSTRUCT) { dns_rdata_ds_t *ds = target; REQUIRE(rdata->type == dns_rdatatype_ds); - REQUIRE(target != NULL); + REQUIRE(ds != NULL); ds->common.rdclass = rdata->rdclass; ds->common.rdtype = rdata->type; diff --git a/lib/dns/rdata/generic/eui48_108.c b/lib/dns/rdata/generic/eui48_108.c index 686f23f8cf..7a65eb421b 100644 --- a/lib/dns/rdata/generic/eui48_108.c +++ b/lib/dns/rdata/generic/eui48_108.c @@ -113,7 +113,7 @@ fromstruct_eui48(ARGS_FROMSTRUCT) { dns_rdata_eui48_t *eui48 = source; REQUIRE(type == dns_rdatatype_eui48); - REQUIRE(source != NULL); + REQUIRE(eui48 != NULL); REQUIRE(eui48->common.rdtype == type); REQUIRE(eui48->common.rdclass == rdclass); @@ -128,7 +128,7 @@ tostruct_eui48(ARGS_TOSTRUCT) { dns_rdata_eui48_t *eui48 = target; REQUIRE(rdata->type == dns_rdatatype_eui48); - REQUIRE(target != NULL); + REQUIRE(eui48 != NULL); REQUIRE(rdata->length == 6); UNUSED(mctx); @@ -145,7 +145,7 @@ static inline void freestruct_eui48(ARGS_FREESTRUCT) { dns_rdata_eui48_t *eui48 = source; - REQUIRE(source != NULL); + REQUIRE(eui48 != NULL); REQUIRE(eui48->common.rdtype == dns_rdatatype_eui48); return; diff --git a/lib/dns/rdata/generic/eui64_109.c b/lib/dns/rdata/generic/eui64_109.c index 0a37326c63..941f3c3747 100644 --- a/lib/dns/rdata/generic/eui64_109.c +++ b/lib/dns/rdata/generic/eui64_109.c @@ -118,7 +118,7 @@ fromstruct_eui64(ARGS_FROMSTRUCT) { dns_rdata_eui64_t *eui64 = source; REQUIRE(type == dns_rdatatype_eui64); - REQUIRE(source != NULL); + REQUIRE(eui64 != NULL); REQUIRE(eui64->common.rdtype == type); REQUIRE(eui64->common.rdclass == rdclass); @@ -133,7 +133,7 @@ tostruct_eui64(ARGS_TOSTRUCT) { dns_rdata_eui64_t *eui64 = target; REQUIRE(rdata->type == dns_rdatatype_eui64); - REQUIRE(target != NULL); + REQUIRE(eui64 != NULL); REQUIRE(rdata->length == 8); UNUSED(mctx); @@ -150,7 +150,7 @@ static inline void freestruct_eui64(ARGS_FREESTRUCT) { dns_rdata_eui64_t *eui64 = source; - REQUIRE(source != NULL); + REQUIRE(eui64 != NULL); REQUIRE(eui64->common.rdtype == dns_rdatatype_eui64); return; diff --git a/lib/dns/rdata/generic/gpos_27.c b/lib/dns/rdata/generic/gpos_27.c index 62429327e4..ead5ca0332 100644 --- a/lib/dns/rdata/generic/gpos_27.c +++ b/lib/dns/rdata/generic/gpos_27.c @@ -107,7 +107,7 @@ fromstruct_gpos(ARGS_FROMSTRUCT) { dns_rdata_gpos_t *gpos = source; REQUIRE(type == dns_rdatatype_gpos); - REQUIRE(source != NULL); + REQUIRE(gpos != NULL); REQUIRE(gpos->common.rdtype == type); REQUIRE(gpos->common.rdclass == rdclass); @@ -128,7 +128,7 @@ tostruct_gpos(ARGS_TOSTRUCT) { isc_region_t region; REQUIRE(rdata->type == dns_rdatatype_gpos); - REQUIRE(target != NULL); + REQUIRE(gpos != NULL); REQUIRE(rdata->length != 0); gpos->common.rdclass = rdata->rdclass; @@ -177,7 +177,7 @@ static inline void freestruct_gpos(ARGS_FREESTRUCT) { dns_rdata_gpos_t *gpos = source; - REQUIRE(source != NULL); + REQUIRE(gpos != NULL); REQUIRE(gpos->common.rdtype == dns_rdatatype_gpos); if (gpos->mctx == NULL) diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index 528be5eb86..0d43a19fb9 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -97,7 +97,7 @@ fromstruct_hinfo(ARGS_FROMSTRUCT) { dns_rdata_hinfo_t *hinfo = source; REQUIRE(type == dns_rdatatype_hinfo); - REQUIRE(source != NULL); + REQUIRE(hinfo != NULL); REQUIRE(hinfo->common.rdtype == type); REQUIRE(hinfo->common.rdclass == rdclass); @@ -116,7 +116,7 @@ tostruct_hinfo(ARGS_TOSTRUCT) { isc_region_t region; REQUIRE(rdata->type == dns_rdatatype_hinfo); - REQUIRE(target != NULL); + REQUIRE(hinfo != NULL); REQUIRE(rdata->length != 0); hinfo->common.rdclass = rdata->rdclass; @@ -150,7 +150,7 @@ static inline void freestruct_hinfo(ARGS_FREESTRUCT) { dns_rdata_hinfo_t *hinfo = source; - REQUIRE(source != NULL); + REQUIRE(hinfo != NULL); if (hinfo->mctx == NULL) return; diff --git a/lib/dns/rdata/generic/hip_55.c b/lib/dns/rdata/generic/hip_55.c index 36c9273e45..7c8f31b148 100644 --- a/lib/dns/rdata/generic/hip_55.c +++ b/lib/dns/rdata/generic/hip_55.c @@ -254,7 +254,7 @@ fromstruct_hip(ARGS_FROMSTRUCT) { isc_result_t result; REQUIRE(type == dns_rdatatype_hip); - REQUIRE(source != NULL); + REQUIRE(hip != NULL); REQUIRE(hip->common.rdtype == type); REQUIRE(hip->common.rdclass == rdclass); REQUIRE(hip->hit_len > 0 && hip->hit != NULL); @@ -286,7 +286,7 @@ tostruct_hip(ARGS_TOSTRUCT) { dns_rdata_hip_t *hip = target; REQUIRE(rdata->type == dns_rdatatype_hip); - REQUIRE(target != NULL); + REQUIRE(hip != NULL); REQUIRE(rdata->length != 0); hip->common.rdclass = rdata->rdclass; @@ -344,7 +344,7 @@ static inline void freestruct_hip(ARGS_FREESTRUCT) { dns_rdata_hip_t *hip = source; - REQUIRE(source != NULL); + REQUIRE(hip != NULL); if (hip->mctx == NULL) return; diff --git a/lib/dns/rdata/generic/ipseckey_45.c b/lib/dns/rdata/generic/ipseckey_45.c index 232f9b9004..ba880ffb66 100644 --- a/lib/dns/rdata/generic/ipseckey_45.c +++ b/lib/dns/rdata/generic/ipseckey_45.c @@ -282,7 +282,7 @@ fromstruct_ipseckey(ARGS_FROMSTRUCT) { uint32_t n; REQUIRE(type == dns_rdatatype_ipseckey); - REQUIRE(source != NULL); + REQUIRE(ipseckey != NULL); REQUIRE(ipseckey->common.rdtype == type); REQUIRE(ipseckey->common.rdclass == rdclass); @@ -326,7 +326,7 @@ tostruct_ipseckey(ARGS_TOSTRUCT) { uint32_t n; REQUIRE(rdata->type == dns_rdatatype_ipseckey); - REQUIRE(target != NULL); + REQUIRE(ipseckey != NULL); REQUIRE(rdata->length >= 3); if (rdata->data[1] > 3U) @@ -392,7 +392,7 @@ static inline void freestruct_ipseckey(ARGS_FREESTRUCT) { dns_rdata_ipseckey_t *ipseckey = source; - REQUIRE(source != NULL); + REQUIRE(ipseckey != NULL); REQUIRE(ipseckey->common.rdtype == dns_rdatatype_ipseckey); if (ipseckey->mctx == NULL) diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c index a73cd1f70a..586142ecef 100644 --- a/lib/dns/rdata/generic/isdn_20.c +++ b/lib/dns/rdata/generic/isdn_20.c @@ -108,7 +108,7 @@ fromstruct_isdn(ARGS_FROMSTRUCT) { dns_rdata_isdn_t *isdn = source; REQUIRE(type == dns_rdatatype_isdn); - REQUIRE(source != NULL); + REQUIRE(isdn != NULL); REQUIRE(isdn->common.rdtype == type); REQUIRE(isdn->common.rdclass == rdclass); @@ -129,7 +129,7 @@ tostruct_isdn(ARGS_TOSTRUCT) { isc_region_t r; REQUIRE(rdata->type == dns_rdatatype_isdn); - REQUIRE(target != NULL); + REQUIRE(isdn != NULL); REQUIRE(rdata->length != 0); isdn->common.rdclass = rdata->rdclass; @@ -170,7 +170,7 @@ static inline void freestruct_isdn(ARGS_FREESTRUCT) { dns_rdata_isdn_t *isdn = source; - REQUIRE(source != NULL); + REQUIRE(isdn != NULL); if (isdn->mctx == NULL) return; diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c index 0cc8b96c50..88f3075dc6 100644 --- a/lib/dns/rdata/generic/key_25.c +++ b/lib/dns/rdata/generic/key_25.c @@ -320,7 +320,7 @@ generic_tostruct_key(ARGS_TOSTRUCT) { dns_rdata_key_t *key = target; isc_region_t sr; - REQUIRE(rdata != NULL); + REQUIRE(key != NULL); REQUIRE(rdata->length != 0); REQUIRE(key != NULL); diff --git a/lib/dns/rdata/generic/keydata_65533.c b/lib/dns/rdata/generic/keydata_65533.c index c4bab947c2..56c92b75fb 100644 --- a/lib/dns/rdata/generic/keydata_65533.c +++ b/lib/dns/rdata/generic/keydata_65533.c @@ -275,7 +275,7 @@ fromstruct_keydata(ARGS_FROMSTRUCT) { dns_rdata_keydata_t *keydata = source; REQUIRE(type == dns_rdatatype_keydata); - REQUIRE(source != NULL); + REQUIRE(keydata != NULL); REQUIRE(keydata->common.rdtype == type); REQUIRE(keydata->common.rdclass == rdclass); @@ -310,7 +310,7 @@ tostruct_keydata(ARGS_TOSTRUCT) { isc_region_t sr; REQUIRE(rdata->type == dns_rdatatype_keydata); - REQUIRE(target != NULL); + REQUIRE(keydata != NULL); keydata->common.rdclass = rdata->rdclass; keydata->common.rdtype = rdata->type; @@ -368,7 +368,7 @@ static inline void freestruct_keydata(ARGS_FREESTRUCT) { dns_rdata_keydata_t *keydata = (dns_rdata_keydata_t *) source; - REQUIRE(source != NULL); + REQUIRE(keydata != NULL); REQUIRE(keydata->common.rdtype == dns_rdatatype_keydata); if (keydata->mctx == NULL) diff --git a/lib/dns/rdata/generic/l32_105.c b/lib/dns/rdata/generic/l32_105.c index cc1b9b2515..c87789f4d5 100644 --- a/lib/dns/rdata/generic/l32_105.c +++ b/lib/dns/rdata/generic/l32_105.c @@ -124,7 +124,7 @@ fromstruct_l32(ARGS_FROMSTRUCT) { uint32_t n; REQUIRE(type == dns_rdatatype_l32); - REQUIRE(source != NULL); + REQUIRE(l32 != NULL); REQUIRE(l32->common.rdtype == type); REQUIRE(l32->common.rdclass == rdclass); @@ -143,7 +143,7 @@ tostruct_l32(ARGS_TOSTRUCT) { uint32_t n; REQUIRE(rdata->type == dns_rdatatype_l32); - REQUIRE(target != NULL); + REQUIRE(l32 != NULL); REQUIRE(rdata->length == 6); UNUSED(mctx); @@ -163,7 +163,7 @@ static inline void freestruct_l32(ARGS_FREESTRUCT) { dns_rdata_l32_t *l32 = source; - REQUIRE(source != NULL); + REQUIRE(l32 != NULL); REQUIRE(l32->common.rdtype == dns_rdatatype_l32); return; diff --git a/lib/dns/rdata/generic/l64_106.c b/lib/dns/rdata/generic/l64_106.c index 277c6a910e..a3e7ab1b0a 100644 --- a/lib/dns/rdata/generic/l64_106.c +++ b/lib/dns/rdata/generic/l64_106.c @@ -122,7 +122,7 @@ fromstruct_l64(ARGS_FROMSTRUCT) { dns_rdata_l64_t *l64 = source; REQUIRE(type == dns_rdatatype_l64); - REQUIRE(source != NULL); + REQUIRE(l64 != NULL); REQUIRE(l64->common.rdtype == type); REQUIRE(l64->common.rdclass == rdclass); @@ -139,7 +139,7 @@ tostruct_l64(ARGS_TOSTRUCT) { dns_rdata_l64_t *l64 = target; REQUIRE(rdata->type == dns_rdatatype_l64); - REQUIRE(target != NULL); + REQUIRE(l64 != NULL); REQUIRE(rdata->length == 10); UNUSED(mctx); @@ -158,7 +158,7 @@ static inline void freestruct_l64(ARGS_FREESTRUCT) { dns_rdata_l64_t *l64 = source; - REQUIRE(source != NULL); + REQUIRE(l64 != NULL); REQUIRE(l64->common.rdtype == dns_rdatatype_l64); return; diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 388742b836..792c8e7300 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -670,7 +670,7 @@ fromstruct_loc(ARGS_FROMSTRUCT) { uint8_t c; REQUIRE(type == dns_rdatatype_loc); - REQUIRE(source != NULL); + REQUIRE(loc != NULL); REQUIRE(loc->common.rdtype == type); REQUIRE(loc->common.rdclass == rdclass); @@ -715,7 +715,7 @@ tostruct_loc(ARGS_TOSTRUCT) { uint8_t version; REQUIRE(rdata->type == dns_rdatatype_loc); - REQUIRE(target != NULL); + REQUIRE(loc != NULL); REQUIRE(rdata->length != 0); UNUSED(mctx); @@ -750,7 +750,7 @@ static inline void freestruct_loc(ARGS_FREESTRUCT) { dns_rdata_loc_t *loc = source; - REQUIRE(source != NULL); + REQUIRE(loc != NULL); REQUIRE(loc->common.rdtype == dns_rdatatype_loc); UNUSED(source); diff --git a/lib/dns/rdata/generic/lp_107.c b/lib/dns/rdata/generic/lp_107.c index 49bc799bd9..87e268f7f6 100644 --- a/lib/dns/rdata/generic/lp_107.c +++ b/lib/dns/rdata/generic/lp_107.c @@ -130,7 +130,7 @@ fromstruct_lp(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_lp); - REQUIRE(source != NULL); + REQUIRE(lp != NULL); REQUIRE(lp->common.rdtype == type); REQUIRE(lp->common.rdclass == rdclass); @@ -149,7 +149,7 @@ tostruct_lp(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_lp); - REQUIRE(target != NULL); + REQUIRE(lp != NULL); REQUIRE(rdata->length != 0); lp->common.rdclass = rdata->rdclass; @@ -171,7 +171,7 @@ static inline void freestruct_lp(ARGS_FREESTRUCT) { dns_rdata_lp_t *lp = source; - REQUIRE(source != NULL); + REQUIRE(lp != NULL); REQUIRE(lp->common.rdtype == dns_rdatatype_lp); if (lp->mctx == NULL) diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c index 299f89d10d..93d85e52bc 100644 --- a/lib/dns/rdata/generic/mb_7.c +++ b/lib/dns/rdata/generic/mb_7.c @@ -122,7 +122,7 @@ fromstruct_mb(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_mb); - REQUIRE(source != NULL); + REQUIRE(mb != NULL); REQUIRE(mb->common.rdtype == type); REQUIRE(mb->common.rdclass == rdclass); @@ -140,7 +140,7 @@ tostruct_mb(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_mb); - REQUIRE(target != NULL); + REQUIRE(mb != NULL); REQUIRE(rdata->length != 0); mb->common.rdclass = rdata->rdclass; @@ -160,7 +160,7 @@ static inline void freestruct_mb(ARGS_FREESTRUCT) { dns_rdata_mb_t *mb = source; - REQUIRE(source != NULL); + REQUIRE(mb != NULL); if (mb->mctx == NULL) return; diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c index 9eefe6967e..8c58d6e8c9 100644 --- a/lib/dns/rdata/generic/md_3.c +++ b/lib/dns/rdata/generic/md_3.c @@ -122,7 +122,7 @@ fromstruct_md(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_md); - REQUIRE(source != NULL); + REQUIRE(md != NULL); REQUIRE(md->common.rdtype == type); REQUIRE(md->common.rdclass == rdclass); @@ -140,7 +140,7 @@ tostruct_md(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_md); - REQUIRE(target != NULL); + REQUIRE(md != NULL); REQUIRE(rdata->length != 0); md->common.rdclass = rdata->rdclass; @@ -160,7 +160,7 @@ static inline void freestruct_md(ARGS_FREESTRUCT) { dns_rdata_md_t *md = source; - REQUIRE(source != NULL); + REQUIRE(md != NULL); REQUIRE(md->common.rdtype == dns_rdatatype_md); if (md->mctx == NULL) diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c index 59659816e6..fa653a683c 100644 --- a/lib/dns/rdata/generic/mf_4.c +++ b/lib/dns/rdata/generic/mf_4.c @@ -122,7 +122,7 @@ fromstruct_mf(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_mf); - REQUIRE(source != NULL); + REQUIRE(mf != NULL); REQUIRE(mf->common.rdtype == type); REQUIRE(mf->common.rdclass == rdclass); @@ -140,7 +140,7 @@ tostruct_mf(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_mf); - REQUIRE(target != NULL); + REQUIRE(mf != NULL); REQUIRE(rdata->length != 0); mf->common.rdclass = rdata->rdclass; @@ -160,7 +160,7 @@ static inline void freestruct_mf(ARGS_FREESTRUCT) { dns_rdata_mf_t *mf = source; - REQUIRE(source != NULL); + REQUIRE(mf != NULL); REQUIRE(mf->common.rdtype == dns_rdatatype_mf); if (mf->mctx == NULL) diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c index 45a38ce751..c631539d20 100644 --- a/lib/dns/rdata/generic/mg_8.c +++ b/lib/dns/rdata/generic/mg_8.c @@ -122,7 +122,7 @@ fromstruct_mg(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_mg); - REQUIRE(source != NULL); + REQUIRE(mg != NULL); REQUIRE(mg->common.rdtype == type); REQUIRE(mg->common.rdclass == rdclass); @@ -140,7 +140,7 @@ tostruct_mg(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_mg); - REQUIRE(target != NULL); + REQUIRE(mg != NULL); REQUIRE(rdata->length != 0); mg->common.rdclass = rdata->rdclass; @@ -160,7 +160,7 @@ static inline void freestruct_mg(ARGS_FREESTRUCT) { dns_rdata_mg_t *mg = source; - REQUIRE(source != NULL); + REQUIRE(mg != NULL); REQUIRE(mg->common.rdtype == dns_rdatatype_mg); if (mg->mctx == NULL) diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index 23506e2082..5b1e8745c7 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -177,7 +177,7 @@ fromstruct_minfo(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_minfo); - REQUIRE(source != NULL); + REQUIRE(minfo != NULL); REQUIRE(minfo->common.rdtype == type); REQUIRE(minfo->common.rdclass == rdclass); @@ -198,7 +198,7 @@ tostruct_minfo(ARGS_TOSTRUCT) { isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_minfo); - REQUIRE(target != NULL); + REQUIRE(minfo != NULL); REQUIRE(rdata->length != 0); minfo->common.rdclass = rdata->rdclass; @@ -230,7 +230,7 @@ static inline void freestruct_minfo(ARGS_FREESTRUCT) { dns_rdata_minfo_t *minfo = source; - REQUIRE(source != NULL); + REQUIRE(minfo != NULL); REQUIRE(minfo->common.rdtype == dns_rdatatype_minfo); if (minfo->mctx == NULL) diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c index edea7b1697..c39bf54083 100644 --- a/lib/dns/rdata/generic/mr_9.c +++ b/lib/dns/rdata/generic/mr_9.c @@ -122,7 +122,7 @@ fromstruct_mr(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_mr); - REQUIRE(source != NULL); + REQUIRE(mr != NULL); REQUIRE(mr->common.rdtype == type); REQUIRE(mr->common.rdclass == rdclass); @@ -140,7 +140,7 @@ tostruct_mr(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_mr); - REQUIRE(target != NULL); + REQUIRE(mr != NULL); REQUIRE(rdata->length != 0); mr->common.rdclass = rdata->rdclass; @@ -160,7 +160,7 @@ static inline void freestruct_mr(ARGS_FREESTRUCT) { dns_rdata_mr_t *mr = source; - REQUIRE(source != NULL); + REQUIRE(mr != NULL); REQUIRE(mr->common.rdtype == dns_rdatatype_mr); if (mr->mctx == NULL) diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index 37a687ccfe..46ac7c67e6 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -193,7 +193,7 @@ fromstruct_mx(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_mx); - REQUIRE(source != NULL); + REQUIRE(mx != NULL); REQUIRE(mx->common.rdtype == type); REQUIRE(mx->common.rdclass == rdclass); @@ -212,7 +212,7 @@ tostruct_mx(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_mx); - REQUIRE(target != NULL); + REQUIRE(mx != NULL); REQUIRE(rdata->length != 0); mx->common.rdclass = rdata->rdclass; @@ -234,7 +234,7 @@ static inline void freestruct_mx(ARGS_FREESTRUCT) { dns_rdata_mx_t *mx = source; - REQUIRE(source != NULL); + REQUIRE(mx != NULL); REQUIRE(mx->common.rdtype == dns_rdatatype_mx); if (mx->mctx == NULL) diff --git a/lib/dns/rdata/generic/naptr_35.c b/lib/dns/rdata/generic/naptr_35.c index 80c8f16729..4d99e2b253 100644 --- a/lib/dns/rdata/generic/naptr_35.c +++ b/lib/dns/rdata/generic/naptr_35.c @@ -402,7 +402,7 @@ fromstruct_naptr(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_naptr); - REQUIRE(source != NULL); + REQUIRE(naptr != NULL); REQUIRE(naptr->common.rdtype == type); REQUIRE(naptr->common.rdclass == rdclass); REQUIRE(naptr->flags != NULL || naptr->flags_len == 0); @@ -432,7 +432,7 @@ tostruct_naptr(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_naptr); - REQUIRE(target != NULL); + REQUIRE(naptr != NULL); REQUIRE(rdata->length != 0); naptr->common.rdclass = rdata->rdclass; @@ -498,7 +498,7 @@ static inline void freestruct_naptr(ARGS_FREESTRUCT) { dns_rdata_naptr_t *naptr = source; - REQUIRE(source != NULL); + REQUIRE(naptr != NULL); REQUIRE(naptr->common.rdtype == dns_rdatatype_naptr); if (naptr->mctx == NULL) diff --git a/lib/dns/rdata/generic/nid_104.c b/lib/dns/rdata/generic/nid_104.c index fee61fd32c..44e63b5ba7 100644 --- a/lib/dns/rdata/generic/nid_104.c +++ b/lib/dns/rdata/generic/nid_104.c @@ -122,7 +122,7 @@ fromstruct_nid(ARGS_FROMSTRUCT) { dns_rdata_nid_t *nid = source; REQUIRE(type == dns_rdatatype_nid); - REQUIRE(source != NULL); + REQUIRE(nid != NULL); REQUIRE(nid->common.rdtype == type); REQUIRE(nid->common.rdclass == rdclass); @@ -139,7 +139,7 @@ tostruct_nid(ARGS_TOSTRUCT) { dns_rdata_nid_t *nid = target; REQUIRE(rdata->type == dns_rdatatype_nid); - REQUIRE(target != NULL); + REQUIRE(nid != NULL); REQUIRE(rdata->length == 10); UNUSED(mctx); @@ -158,7 +158,7 @@ static inline void freestruct_nid(ARGS_FREESTRUCT) { dns_rdata_nid_t *nid = source; - REQUIRE(source != NULL); + REQUIRE(nid != NULL); REQUIRE(nid->common.rdtype == dns_rdatatype_nid); return; diff --git a/lib/dns/rdata/generic/ninfo_56.c b/lib/dns/rdata/generic/ninfo_56.c index fe8957affa..1101ba1a77 100644 --- a/lib/dns/rdata/generic/ninfo_56.c +++ b/lib/dns/rdata/generic/ninfo_56.c @@ -87,13 +87,14 @@ fromstruct_ninfo(ARGS_FROMSTRUCT) { static inline isc_result_t tostruct_ninfo(ARGS_TOSTRUCT) { - dns_rdata_ninfo_t *txt = target; + dns_rdata_ninfo_t *ninfo = target; REQUIRE(rdata->type == dns_rdatatype_ninfo); + REQUIRE(ninfo != NULL); - txt->common.rdclass = rdata->rdclass; - txt->common.rdtype = rdata->type; - ISC_LINK_INIT(&txt->common, link); + ninfo->common.rdclass = rdata->rdclass; + ninfo->common.rdtype = rdata->type; + ISC_LINK_INIT(&ninfo->common, link); return (generic_tostruct_txt(rdata, target, mctx)); } @@ -102,7 +103,7 @@ static inline void freestruct_ninfo(ARGS_FREESTRUCT) { dns_rdata_ninfo_t *ninfo = source; - REQUIRE(source != NULL); + REQUIRE(ninfo != NULL); REQUIRE(ninfo->common.rdtype == dns_rdatatype_ninfo); generic_freestruct_txt(source); diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index 7f3979f622..ac552529fb 100644 --- a/lib/dns/rdata/generic/ns_2.c +++ b/lib/dns/rdata/generic/ns_2.c @@ -130,7 +130,7 @@ fromstruct_ns(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_ns); - REQUIRE(source != NULL); + REQUIRE(ns != NULL); REQUIRE(ns->common.rdtype == type); REQUIRE(ns->common.rdclass == rdclass); @@ -148,7 +148,7 @@ tostruct_ns(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_ns); - REQUIRE(target != NULL); + REQUIRE(ns != NULL); REQUIRE(rdata->length != 0); ns->common.rdclass = rdata->rdclass; @@ -168,7 +168,7 @@ static inline void freestruct_ns(ARGS_FREESTRUCT) { dns_rdata_ns_t *ns = source; - REQUIRE(source != NULL); + REQUIRE(ns != NULL); if (ns->mctx == NULL) return; diff --git a/lib/dns/rdata/generic/nsec3_50.c b/lib/dns/rdata/generic/nsec3_50.c index 1aedf22438..b1aee3e670 100644 --- a/lib/dns/rdata/generic/nsec3_50.c +++ b/lib/dns/rdata/generic/nsec3_50.c @@ -249,7 +249,7 @@ fromstruct_nsec3(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_nsec3); - REQUIRE(source != NULL); + REQUIRE(nsec3 != NULL); REQUIRE(nsec3->common.rdtype == type); REQUIRE(nsec3->common.rdclass == rdclass); REQUIRE(nsec3->typebits != NULL || nsec3->len == 0); @@ -278,7 +278,7 @@ tostruct_nsec3(ARGS_TOSTRUCT) { dns_rdata_nsec3_t *nsec3 = target; REQUIRE(rdata->type == dns_rdatatype_nsec3); - REQUIRE(target != NULL); + REQUIRE(nsec3 != NULL); REQUIRE(rdata->length != 0); nsec3->common.rdclass = rdata->rdclass; @@ -322,7 +322,7 @@ static inline void freestruct_nsec3(ARGS_FREESTRUCT) { dns_rdata_nsec3_t *nsec3 = source; - REQUIRE(source != NULL); + REQUIRE(nsec3 != NULL); REQUIRE(nsec3->common.rdtype == dns_rdatatype_nsec3); if (nsec3->mctx == NULL) diff --git a/lib/dns/rdata/generic/nsec3param_51.c b/lib/dns/rdata/generic/nsec3param_51.c index 8a24deea03..4e7c4c96fa 100644 --- a/lib/dns/rdata/generic/nsec3param_51.c +++ b/lib/dns/rdata/generic/nsec3param_51.c @@ -198,7 +198,7 @@ fromstruct_nsec3param(ARGS_FROMSTRUCT) { dns_rdata_nsec3param_t *nsec3param = source; REQUIRE(type == dns_rdatatype_nsec3param); - REQUIRE(source != NULL); + REQUIRE(nsec3param != NULL); REQUIRE(nsec3param->common.rdtype == type); REQUIRE(nsec3param->common.rdclass == rdclass); @@ -220,7 +220,7 @@ tostruct_nsec3param(ARGS_TOSTRUCT) { dns_rdata_nsec3param_t *nsec3param = target; REQUIRE(rdata->type == dns_rdatatype_nsec3param); - REQUIRE(target != NULL); + REQUIRE(nsec3param != NULL); REQUIRE(rdata->length != 0); nsec3param->common.rdclass = rdata->rdclass; @@ -248,7 +248,7 @@ static inline void freestruct_nsec3param(ARGS_FREESTRUCT) { dns_rdata_nsec3param_t *nsec3param = source; - REQUIRE(source != NULL); + REQUIRE(nsec3param != NULL); REQUIRE(nsec3param->common.rdtype == dns_rdatatype_nsec3param); if (nsec3param->mctx == NULL) diff --git a/lib/dns/rdata/generic/nsec_47.c b/lib/dns/rdata/generic/nsec_47.c index 0ba688cec0..824d5d3b45 100644 --- a/lib/dns/rdata/generic/nsec_47.c +++ b/lib/dns/rdata/generic/nsec_47.c @@ -135,7 +135,7 @@ fromstruct_nsec(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_nsec); - REQUIRE(source != NULL); + REQUIRE(nsec != NULL); REQUIRE(nsec->common.rdtype == type); REQUIRE(nsec->common.rdclass == rdclass); REQUIRE(nsec->typebits != NULL || nsec->len == 0); @@ -159,7 +159,7 @@ tostruct_nsec(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_nsec); - REQUIRE(target != NULL); + REQUIRE(nsec != NULL); REQUIRE(rdata->length != 0); nsec->common.rdclass = rdata->rdclass; @@ -191,7 +191,7 @@ static inline void freestruct_nsec(ARGS_FREESTRUCT) { dns_rdata_nsec_t *nsec = source; - REQUIRE(source != NULL); + REQUIRE(nsec != NULL); REQUIRE(nsec->common.rdtype == dns_rdatatype_nsec); if (nsec->mctx == NULL) diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c index 624adade55..5ffdb71e11 100644 --- a/lib/dns/rdata/generic/null_10.c +++ b/lib/dns/rdata/generic/null_10.c @@ -80,7 +80,7 @@ fromstruct_null(ARGS_FROMSTRUCT) { dns_rdata_null_t *null = source; REQUIRE(type == dns_rdatatype_null); - REQUIRE(source != NULL); + REQUIRE(null != NULL); REQUIRE(null->common.rdtype == type); REQUIRE(null->common.rdclass == rdclass); REQUIRE(null->data != NULL || null->length == 0); @@ -97,7 +97,7 @@ tostruct_null(ARGS_TOSTRUCT) { isc_region_t r; REQUIRE(rdata->type == dns_rdatatype_null); - REQUIRE(target != NULL); + REQUIRE(null != NULL); null->common.rdclass = rdata->rdclass; null->common.rdtype = rdata->type; @@ -117,7 +117,7 @@ static inline void freestruct_null(ARGS_FREESTRUCT) { dns_rdata_null_t *null = source; - REQUIRE(source != NULL); + REQUIRE(null != NULL); REQUIRE(null->common.rdtype == dns_rdatatype_null); if (null->mctx == NULL) diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c index f9efc3f361..ba8c87bb24 100644 --- a/lib/dns/rdata/generic/nxt_30.c +++ b/lib/dns/rdata/generic/nxt_30.c @@ -197,7 +197,7 @@ fromstruct_nxt(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_nxt); - REQUIRE(source != NULL); + REQUIRE(nxt != NULL); REQUIRE(nxt->common.rdtype == type); REQUIRE(nxt->common.rdclass == rdclass); REQUIRE(nxt->typebits != NULL || nxt->len == 0); @@ -222,7 +222,7 @@ tostruct_nxt(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_nxt); - REQUIRE(target != NULL); + REQUIRE(nxt != NULL); REQUIRE(rdata->length != 0); nxt->common.rdclass = rdata->rdclass; @@ -254,7 +254,7 @@ static inline void freestruct_nxt(ARGS_FREESTRUCT) { dns_rdata_nxt_t *nxt = source; - REQUIRE(source != NULL); + REQUIRE(nxt != NULL); REQUIRE(nxt->common.rdtype == dns_rdatatype_nxt); if (nxt->mctx == NULL) diff --git a/lib/dns/rdata/generic/openpgpkey_61.c b/lib/dns/rdata/generic/openpgpkey_61.c index e2c55a8c3e..900d665c2e 100644 --- a/lib/dns/rdata/generic/openpgpkey_61.c +++ b/lib/dns/rdata/generic/openpgpkey_61.c @@ -116,7 +116,7 @@ fromstruct_openpgpkey(ARGS_FROMSTRUCT) { dns_rdata_openpgpkey_t *sig = source; REQUIRE(type == dns_rdatatype_openpgpkey); - REQUIRE(source != NULL); + REQUIRE(sig != NULL); REQUIRE(sig->common.rdtype == type); REQUIRE(sig->common.rdclass == rdclass); REQUIRE(sig->keyring != NULL && sig->length != 0); @@ -136,7 +136,7 @@ tostruct_openpgpkey(ARGS_TOSTRUCT) { dns_rdata_openpgpkey_t *sig = target; REQUIRE(rdata->type == dns_rdatatype_openpgpkey); - REQUIRE(target != NULL); + REQUIRE(sig != NULL); REQUIRE(rdata->length != 0); sig->common.rdclass = rdata->rdclass; @@ -164,7 +164,7 @@ static inline void freestruct_openpgpkey(ARGS_FREESTRUCT) { dns_rdata_openpgpkey_t *sig = (dns_rdata_openpgpkey_t *) source; - REQUIRE(source != NULL); + REQUIRE(sig != NULL); REQUIRE(sig->common.rdtype == dns_rdatatype_openpgpkey); if (sig->mctx == NULL) diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index 0fe7243f64..d361e13a3a 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -260,7 +260,7 @@ fromstruct_opt(ARGS_FROMSTRUCT) { uint16_t length; REQUIRE(type == dns_rdatatype_opt); - REQUIRE(source != NULL); + REQUIRE(opt != NULL); REQUIRE(opt->common.rdtype == type); REQUIRE(opt->common.rdclass == rdclass); REQUIRE(opt->options != NULL || opt->length == 0); @@ -290,7 +290,7 @@ tostruct_opt(ARGS_TOSTRUCT) { isc_region_t r; REQUIRE(rdata->type == dns_rdatatype_opt); - REQUIRE(target != NULL); + REQUIRE(opt != NULL); opt->common.rdclass = rdata->rdclass; opt->common.rdtype = rdata->type; @@ -311,7 +311,7 @@ static inline void freestruct_opt(ARGS_FREESTRUCT) { dns_rdata_opt_t *opt = source; - REQUIRE(source != NULL); + REQUIRE(opt != NULL); REQUIRE(opt->common.rdtype == dns_rdatatype_opt); if (opt->mctx == NULL) diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c index c31b29f731..7ed78acbdf 100644 --- a/lib/dns/rdata/generic/proforma.c +++ b/lib/dns/rdata/generic/proforma.c @@ -86,7 +86,7 @@ fromstruct_#(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_proforma.c#); REQUIRE(rdclass == #); - REQUIRE(source != NULL); + REQUIRE(# != NULL); REQUIRE(#->common.rdtype == dns_rdatatype_proforma.ctype); REQUIRE(#->common.rdclass == rdclass); @@ -107,7 +107,7 @@ static inline void freestruct_#(ARGS_FREESTRUCT) { dns_rdata_#_t *# = source; - REQUIRE(source != NULL); + REQUIRE(# != NULL); REQUIRE(#->common.rdtype == dns_rdatatype_proforma.c#); REQUIRE(#->common.rdclass == #); diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index a2f5ef1c61..1e405152ba 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -132,7 +132,7 @@ fromstruct_ptr(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_ptr); - REQUIRE(source != NULL); + REQUIRE(ptr != NULL); REQUIRE(ptr->common.rdtype == type); REQUIRE(ptr->common.rdclass == rdclass); @@ -150,7 +150,7 @@ tostruct_ptr(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_ptr); - REQUIRE(target != NULL); + REQUIRE(ptr != NULL); REQUIRE(rdata->length != 0); ptr->common.rdclass = rdata->rdclass; @@ -170,7 +170,7 @@ static inline void freestruct_ptr(ARGS_FREESTRUCT) { dns_rdata_ptr_t *ptr = source; - REQUIRE(source != NULL); + REQUIRE(ptr != NULL); REQUIRE(ptr->common.rdtype == dns_rdatatype_ptr); if (ptr->mctx == NULL) diff --git a/lib/dns/rdata/generic/rp_17.c b/lib/dns/rdata/generic/rp_17.c index 2e91565805..ee2eef22fd 100644 --- a/lib/dns/rdata/generic/rp_17.c +++ b/lib/dns/rdata/generic/rp_17.c @@ -177,7 +177,7 @@ fromstruct_rp(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_rp); - REQUIRE(source != NULL); + REQUIRE(rp != NULL); REQUIRE(rp->common.rdtype == type); REQUIRE(rp->common.rdclass == rdclass); @@ -198,7 +198,7 @@ tostruct_rp(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_rp); - REQUIRE(target != NULL); + REQUIRE(rp != NULL); REQUIRE(rdata->length != 0); rp->common.rdclass = rdata->rdclass; @@ -230,7 +230,7 @@ static inline void freestruct_rp(ARGS_FREESTRUCT) { dns_rdata_rp_t *rp = source; - REQUIRE(source != NULL); + REQUIRE(rp != NULL); REQUIRE(rp->common.rdtype == dns_rdatatype_rp); if (rp->mctx == NULL) diff --git a/lib/dns/rdata/generic/rrsig_46.c b/lib/dns/rdata/generic/rrsig_46.c index d3e6a56256..975810f265 100644 --- a/lib/dns/rdata/generic/rrsig_46.c +++ b/lib/dns/rdata/generic/rrsig_46.c @@ -356,7 +356,7 @@ fromstruct_rrsig(ARGS_FROMSTRUCT) { dns_rdata_rrsig_t *sig = source; REQUIRE(type == dns_rdatatype_rrsig); - REQUIRE(source != NULL); + REQUIRE(sig != NULL); REQUIRE(sig->common.rdtype == type); REQUIRE(sig->common.rdclass == rdclass); REQUIRE(sig->signature != NULL || sig->siglen == 0); @@ -417,7 +417,7 @@ tostruct_rrsig(ARGS_TOSTRUCT) { dns_name_t signer; REQUIRE(rdata->type == dns_rdatatype_rrsig); - REQUIRE(target != NULL); + REQUIRE(sig != NULL); REQUIRE(rdata->length != 0); sig->common.rdclass = rdata->rdclass; @@ -496,7 +496,7 @@ static inline void freestruct_rrsig(ARGS_FREESTRUCT) { dns_rdata_rrsig_t *sig = (dns_rdata_rrsig_t *) source; - REQUIRE(source != NULL); + REQUIRE(sig != NULL); REQUIRE(sig->common.rdtype == dns_rdatatype_rrsig); if (sig->mctx == NULL) diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c index e6450cb0d0..43c08628f8 100644 --- a/lib/dns/rdata/generic/rt_21.c +++ b/lib/dns/rdata/generic/rt_21.c @@ -170,7 +170,7 @@ fromstruct_rt(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_rt); - REQUIRE(source != NULL); + REQUIRE(rt != NULL); REQUIRE(rt->common.rdtype == type); REQUIRE(rt->common.rdclass == rdclass); @@ -189,7 +189,7 @@ tostruct_rt(ARGS_TOSTRUCT) { dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_rt); - REQUIRE(target != NULL); + REQUIRE(rt != NULL); REQUIRE(rdata->length != 0); rt->common.rdclass = rdata->rdclass; @@ -212,7 +212,7 @@ static inline void freestruct_rt(ARGS_FREESTRUCT) { dns_rdata_rt_t *rt = source; - REQUIRE(source != NULL); + REQUIRE(rt != NULL); REQUIRE(rt->common.rdtype == dns_rdatatype_rt); if (rt->mctx == NULL) diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c index 87b20316b5..47a69e8633 100644 --- a/lib/dns/rdata/generic/sig_24.c +++ b/lib/dns/rdata/generic/sig_24.c @@ -355,7 +355,7 @@ fromstruct_sig(ARGS_FROMSTRUCT) { dns_rdata_sig_t *sig = source; REQUIRE(type == dns_rdatatype_sig); - REQUIRE(source != NULL); + REQUIRE(sig != NULL); REQUIRE(sig->common.rdtype == type); REQUIRE(sig->common.rdclass == rdclass); REQUIRE(sig->signature != NULL || sig->siglen == 0); @@ -416,7 +416,7 @@ tostruct_sig(ARGS_TOSTRUCT) { dns_name_t signer; REQUIRE(rdata->type == dns_rdatatype_sig); - REQUIRE(target != NULL); + REQUIRE(sig != NULL); REQUIRE(rdata->length != 0); sig->common.rdclass = rdata->rdclass; @@ -495,7 +495,7 @@ static inline void freestruct_sig(ARGS_FREESTRUCT) { dns_rdata_sig_t *sig = (dns_rdata_sig_t *) source; - REQUIRE(source != NULL); + REQUIRE(sig != NULL); REQUIRE(sig->common.rdtype == dns_rdatatype_sig); if (sig->mctx == NULL) diff --git a/lib/dns/rdata/generic/sink_40.c b/lib/dns/rdata/generic/sink_40.c index 128941440d..13f8562d8c 100644 --- a/lib/dns/rdata/generic/sink_40.c +++ b/lib/dns/rdata/generic/sink_40.c @@ -146,7 +146,7 @@ fromstruct_sink(ARGS_FROMSTRUCT) { dns_rdata_sink_t *sink = source; REQUIRE(type == dns_rdatatype_sink); - REQUIRE(source != NULL); + REQUIRE(sink != NULL); REQUIRE(sink->common.rdtype == type); REQUIRE(sink->common.rdclass == rdclass); @@ -172,7 +172,7 @@ tostruct_sink(ARGS_TOSTRUCT) { isc_region_t sr; REQUIRE(rdata->type == dns_rdatatype_sink); - REQUIRE(target != NULL); + REQUIRE(sink != NULL); REQUIRE(rdata->length >= 3); sink->common.rdclass = rdata->rdclass; @@ -213,7 +213,7 @@ static inline void freestruct_sink(ARGS_FREESTRUCT) { dns_rdata_sink_t *sink = (dns_rdata_sink_t *) source; - REQUIRE(source != NULL); + REQUIRE(sink != NULL); REQUIRE(sink->common.rdtype == dns_rdatatype_sink); if (sink->mctx == NULL) diff --git a/lib/dns/rdata/generic/smimea_53.c b/lib/dns/rdata/generic/smimea_53.c index efd7f0178b..152ad9cfa0 100644 --- a/lib/dns/rdata/generic/smimea_53.c +++ b/lib/dns/rdata/generic/smimea_53.c @@ -81,8 +81,9 @@ static inline isc_result_t tostruct_smimea(ARGS_TOSTRUCT) { dns_rdata_smimea_t *smimea = target; + REQUIRE(rdata != NULL); REQUIRE(rdata->type == dns_rdatatype_smimea); - REQUIRE(target != NULL); + REQUIRE(smimea != NULL); smimea->common.rdclass = rdata->rdclass; smimea->common.rdtype = rdata->type; @@ -95,7 +96,7 @@ static inline void freestruct_smimea(ARGS_FREESTRUCT) { dns_rdata_smimea_t *smimea = source; - REQUIRE(source != NULL); + REQUIRE(smimea != NULL); REQUIRE(smimea->common.rdtype == dns_rdatatype_smimea); generic_freestruct_tlsa(source); diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index 805aaa1882..e93ac6e428 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -274,7 +274,7 @@ fromstruct_soa(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_soa); - REQUIRE(source != NULL); + REQUIRE(soa != NULL); REQUIRE(soa->common.rdtype == type); REQUIRE(soa->common.rdclass == rdclass); @@ -300,7 +300,7 @@ tostruct_soa(ARGS_TOSTRUCT) { isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_soa); - REQUIRE(target != NULL); + REQUIRE(soa != NULL); REQUIRE(rdata->length != 0); soa->common.rdclass = rdata->rdclass; @@ -350,7 +350,7 @@ static inline void freestruct_soa(ARGS_FREESTRUCT) { dns_rdata_soa_t *soa = source; - REQUIRE(source != NULL); + REQUIRE(soa != NULL); REQUIRE(soa->common.rdtype == dns_rdatatype_soa); if (soa->mctx == NULL) diff --git a/lib/dns/rdata/generic/spf_99.c b/lib/dns/rdata/generic/spf_99.c index c41edf6744..3668d9c76f 100644 --- a/lib/dns/rdata/generic/spf_99.c +++ b/lib/dns/rdata/generic/spf_99.c @@ -89,8 +89,9 @@ static inline isc_result_t tostruct_spf(ARGS_TOSTRUCT) { dns_rdata_spf_t *spf = target; + REQUIRE(spf != NULL); + REQUIRE(rdata != NULL); REQUIRE(rdata->type == dns_rdatatype_spf); - REQUIRE(target != NULL); spf->common.rdclass = rdata->rdclass; spf->common.rdtype = rdata->type; @@ -101,10 +102,10 @@ tostruct_spf(ARGS_TOSTRUCT) { static inline void freestruct_spf(ARGS_FREESTRUCT) { - dns_rdata_spf_t *txt = source; + dns_rdata_spf_t *spf = source; - REQUIRE(source != NULL); - REQUIRE(txt->common.rdtype == dns_rdatatype_spf); + REQUIRE(spf != NULL); + REQUIRE(spf->common.rdtype == dns_rdatatype_spf); generic_freestruct_txt(source); } diff --git a/lib/dns/rdata/generic/sshfp_44.c b/lib/dns/rdata/generic/sshfp_44.c index ce60be5ae5..853416eb94 100644 --- a/lib/dns/rdata/generic/sshfp_44.c +++ b/lib/dns/rdata/generic/sshfp_44.c @@ -176,7 +176,7 @@ fromstruct_sshfp(ARGS_FROMSTRUCT) { dns_rdata_sshfp_t *sshfp = source; REQUIRE(type == dns_rdatatype_sshfp); - REQUIRE(source != NULL); + REQUIRE(sshfp != NULL); REQUIRE(sshfp->common.rdtype == type); REQUIRE(sshfp->common.rdclass == rdclass); @@ -195,7 +195,7 @@ tostruct_sshfp(ARGS_TOSTRUCT) { isc_region_t region; REQUIRE(rdata->type == dns_rdatatype_sshfp); - REQUIRE(target != NULL); + REQUIRE(sshfp != NULL); REQUIRE(rdata->length != 0); sshfp->common.rdclass = rdata->rdclass; diff --git a/lib/dns/rdata/generic/ta_32768.c b/lib/dns/rdata/generic/ta_32768.c index 12ec6e7ee8..0a38619a48 100644 --- a/lib/dns/rdata/generic/ta_32768.c +++ b/lib/dns/rdata/generic/ta_32768.c @@ -84,6 +84,7 @@ tostruct_ta(ARGS_TOSTRUCT) { dns_rdata_ds_t *ds = target; REQUIRE(rdata->type == dns_rdatatype_ta); + REQUIRE(ds != NULL); /* * Checked by generic_tostruct_ds(). diff --git a/lib/dns/rdata/generic/talink_58.c b/lib/dns/rdata/generic/talink_58.c index 7f6bacb74f..f286982aa7 100644 --- a/lib/dns/rdata/generic/talink_58.c +++ b/lib/dns/rdata/generic/talink_58.c @@ -144,7 +144,7 @@ fromstruct_talink(ARGS_FROMSTRUCT) { isc_region_t region; REQUIRE(type == dns_rdatatype_talink); - REQUIRE(source != NULL); + REQUIRE(talink != NULL); REQUIRE(talink->common.rdtype == type); REQUIRE(talink->common.rdclass == rdclass); @@ -165,7 +165,7 @@ tostruct_talink(ARGS_TOSTRUCT) { isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_talink); - REQUIRE(target != NULL); + REQUIRE(talink != NULL); REQUIRE(rdata->length != 0); talink->common.rdclass = rdata->rdclass; @@ -200,7 +200,7 @@ static inline void freestruct_talink(ARGS_FREESTRUCT) { dns_rdata_talink_t *talink = source; - REQUIRE(source != NULL); + REQUIRE(talink != NULL); REQUIRE(talink->common.rdtype == dns_rdatatype_talink); if (talink->mctx == NULL) diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c index 7bbd1d3479..3a05f9e04e 100644 --- a/lib/dns/rdata/generic/tkey_249.c +++ b/lib/dns/rdata/generic/tkey_249.c @@ -343,7 +343,7 @@ fromstruct_tkey(ARGS_FROMSTRUCT) { dns_rdata_tkey_t *tkey = source; REQUIRE(type == dns_rdatatype_tkey); - REQUIRE(source != NULL); + REQUIRE(tkey != NULL); REQUIRE(tkey->common.rdtype == type); REQUIRE(tkey->common.rdclass == rdclass); @@ -403,7 +403,7 @@ tostruct_tkey(ARGS_TOSTRUCT) { isc_region_t sr; REQUIRE(rdata->type == dns_rdatatype_tkey); - REQUIRE(target != NULL); + REQUIRE(tkey != NULL); REQUIRE(rdata->length != 0); tkey->common.rdclass = rdata->rdclass; @@ -489,7 +489,7 @@ static inline void freestruct_tkey(ARGS_FREESTRUCT) { dns_rdata_tkey_t *tkey = (dns_rdata_tkey_t *) source; - REQUIRE(source != NULL); + REQUIRE(tkey != NULL); if (tkey->mctx == NULL) return; diff --git a/lib/dns/rdata/generic/tlsa_52.c b/lib/dns/rdata/generic/tlsa_52.c index 69867e72bf..1eeb8d263d 100644 --- a/lib/dns/rdata/generic/tlsa_52.c +++ b/lib/dns/rdata/generic/tlsa_52.c @@ -188,7 +188,7 @@ static inline isc_result_t generic_fromstruct_tlsa(ARGS_FROMSTRUCT) { dns_rdata_tlsa_t *tlsa = source; - REQUIRE(source != NULL); + REQUIRE(tlsa != NULL); REQUIRE(tlsa->common.rdtype == type); REQUIRE(tlsa->common.rdclass == rdclass); @@ -207,7 +207,7 @@ generic_tostruct_tlsa(ARGS_TOSTRUCT) { dns_rdata_tlsa_t *tlsa = target; isc_region_t region; - REQUIRE(rdata != NULL); + REQUIRE(tlsa != NULL); REQUIRE(rdata->length != 0); REQUIRE(tlsa != NULL); @@ -260,7 +260,7 @@ tostruct_tlsa(ARGS_TOSTRUCT) { dns_rdata_tlsa_t *tlsa = target; REQUIRE(rdata->type == dns_rdatatype_tlsa); - REQUIRE(target != NULL); + REQUIRE(tlsa != NULL); tlsa->common.rdclass = rdata->rdclass; tlsa->common.rdtype = rdata->type; @@ -273,7 +273,7 @@ static inline void freestruct_tlsa(ARGS_FREESTRUCT) { dns_rdata_tlsa_t *tlsa = source; - REQUIRE(source != NULL); + REQUIRE(tlsa != NULL); REQUIRE(tlsa->common.rdtype == dns_rdatatype_tlsa); generic_freestruct_tlsa(source); diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 3f3842e6b0..21b0e4539e 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -138,7 +138,7 @@ generic_fromstruct_txt(ARGS_FROMSTRUCT) { isc_region_t region; uint8_t length; - REQUIRE(source != NULL); + REQUIRE(txt != NULL); REQUIRE(txt->common.rdtype == type); REQUIRE(txt->common.rdclass == rdclass); REQUIRE(txt->txt != NULL && txt->txt_len != 0); @@ -164,7 +164,7 @@ generic_tostruct_txt(ARGS_TOSTRUCT) { dns_rdata_txt_t *txt = target; isc_region_t r; - REQUIRE(target != NULL); + REQUIRE(txt != NULL); REQUIRE(txt->common.rdclass == rdata->rdclass); REQUIRE(txt->common.rdtype == rdata->type); REQUIRE(!ISC_LINK_LINKED(&txt->common, link)); @@ -184,7 +184,7 @@ static inline void generic_freestruct_txt(ARGS_FREESTRUCT) { dns_rdata_txt_t *txt = source; - REQUIRE(source != NULL); + REQUIRE(txt != NULL); if (txt->mctx == NULL) return; @@ -207,7 +207,7 @@ tostruct_txt(ARGS_TOSTRUCT) { dns_rdata_txt_t *txt = target; REQUIRE(rdata->type == dns_rdatatype_txt); - REQUIRE(target != NULL); + REQUIRE(txt != NULL); txt->common.rdclass = rdata->rdclass; txt->common.rdtype = rdata->type; @@ -220,7 +220,7 @@ static inline void freestruct_txt(ARGS_FREESTRUCT) { dns_rdata_txt_t *txt = source; - REQUIRE(source != NULL); + REQUIRE(txt != NULL); REQUIRE(txt->common.rdtype == dns_rdatatype_txt); generic_freestruct_txt(source); diff --git a/lib/dns/rdata/generic/uri_256.c b/lib/dns/rdata/generic/uri_256.c index 8fb0307d28..0a8801a81e 100644 --- a/lib/dns/rdata/generic/uri_256.c +++ b/lib/dns/rdata/generic/uri_256.c @@ -171,7 +171,7 @@ fromstruct_uri(ARGS_FROMSTRUCT) { dns_rdata_uri_t *uri = source; REQUIRE(type == dns_rdatatype_uri); - REQUIRE(source != NULL); + REQUIRE(uri != NULL); REQUIRE(uri->common.rdtype == type); REQUIRE(uri->common.rdclass == rdclass); REQUIRE(uri->target != NULL && uri->tgt_len != 0); @@ -201,7 +201,7 @@ tostruct_uri(ARGS_TOSTRUCT) { isc_region_t sr; REQUIRE(rdata->type == dns_rdatatype_uri); - REQUIRE(target != NULL); + REQUIRE(uri != NULL); REQUIRE(rdata->length != 0); uri->common.rdclass = rdata->rdclass; @@ -242,7 +242,7 @@ static inline void freestruct_uri(ARGS_FREESTRUCT) { dns_rdata_uri_t *uri = (dns_rdata_uri_t *) source; - REQUIRE(source != NULL); + REQUIRE(uri != NULL); REQUIRE(uri->common.rdtype == dns_rdatatype_uri); if (uri->mctx == NULL) diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c index d267f65151..5dc9e2e36e 100644 --- a/lib/dns/rdata/generic/x25_19.c +++ b/lib/dns/rdata/generic/x25_19.c @@ -102,7 +102,7 @@ fromstruct_x25(ARGS_FROMSTRUCT) { uint8_t i; REQUIRE(type == dns_rdatatype_x25); - REQUIRE(source != NULL); + REQUIRE(x25 != NULL); REQUIRE(x25->common.rdtype == type); REQUIRE(x25->common.rdclass == rdclass); REQUIRE(x25->x25 != NULL && x25->x25_len != 0); @@ -127,7 +127,7 @@ tostruct_x25(ARGS_TOSTRUCT) { isc_region_t r; REQUIRE(rdata->type == dns_rdatatype_x25); - REQUIRE(target != NULL); + REQUIRE(x25 != NULL); REQUIRE(rdata->length != 0); x25->common.rdclass = rdata->rdclass; @@ -148,7 +148,8 @@ tostruct_x25(ARGS_TOSTRUCT) { static inline void freestruct_x25(ARGS_FREESTRUCT) { dns_rdata_x25_t *x25 = source; - REQUIRE(source != NULL); + + REQUIRE(x25 != NULL); REQUIRE(x25->common.rdtype == dns_rdatatype_x25); if (x25->mctx == NULL) diff --git a/lib/dns/rdata/generic/zonemd_63.c b/lib/dns/rdata/generic/zonemd_63.c index 604a901d3e..0c91806354 100644 --- a/lib/dns/rdata/generic/zonemd_63.c +++ b/lib/dns/rdata/generic/zonemd_63.c @@ -196,7 +196,7 @@ static inline isc_result_t fromstruct_zonemd(ARGS_FROMSTRUCT) { dns_rdata_zonemd_t *zonemd = source; - REQUIRE(source != NULL); + REQUIRE(zonemd != NULL); REQUIRE(zonemd->common.rdtype == type); REQUIRE(zonemd->common.rdclass == rdclass); @@ -222,7 +222,7 @@ tostruct_zonemd(ARGS_TOSTRUCT) { isc_region_t region; REQUIRE(rdata->type == dns_rdatatype_zonemd); - REQUIRE(target != NULL); + REQUIRE(zonemd != NULL); REQUIRE(rdata->length != 0); zonemd->common.rdclass = rdata->rdclass; diff --git a/lib/dns/rdata/hs_4/a_1.c b/lib/dns/rdata/hs_4/a_1.c index bfa59e25ed..93c6183d63 100644 --- a/lib/dns/rdata/hs_4/a_1.c +++ b/lib/dns/rdata/hs_4/a_1.c @@ -127,7 +127,7 @@ fromstruct_hs_a(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_a); REQUIRE(rdclass == dns_rdataclass_hs); - REQUIRE(source != NULL); + REQUIRE(a != NULL); REQUIRE(a->common.rdtype == type); REQUIRE(a->common.rdclass == rdclass); @@ -148,6 +148,7 @@ tostruct_hs_a(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_hs); REQUIRE(rdata->length == 4); + REQUIRE(a != NULL); UNUSED(mctx); diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index 9d7d431ed5..20213f555f 100644 --- a/lib/dns/rdata/in_1/a6_38.c +++ b/lib/dns/rdata/in_1/a6_38.c @@ -279,7 +279,7 @@ fromstruct_in_a6(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_a6); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(a6 != NULL); REQUIRE(a6->common.rdtype == type); REQUIRE(a6->common.rdclass == rdclass); @@ -322,7 +322,7 @@ tostruct_in_a6(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_a6); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(a6 != NULL); REQUIRE(rdata->length != 0); a6->common.rdclass = rdata->rdclass; @@ -362,7 +362,7 @@ static inline void freestruct_in_a6(ARGS_FREESTRUCT) { dns_rdata_in_a6_t *a6 = source; - REQUIRE(source != NULL); + REQUIRE(a6 != NULL); REQUIRE(a6->common.rdclass == dns_rdataclass_in); REQUIRE(a6->common.rdtype == dns_rdatatype_a6); diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index 588c5ec0d4..81f87b0113 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -128,7 +128,7 @@ fromstruct_in_a(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_a); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(a != NULL); REQUIRE(a->common.rdtype == type); REQUIRE(a->common.rdclass == rdclass); @@ -147,6 +147,7 @@ tostruct_in_a(ARGS_TOSTRUCT) { uint32_t n; isc_region_t region; + REQUIRE(a != NULL); REQUIRE(rdata->type == dns_rdatatype_a); REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length == 4); @@ -168,7 +169,7 @@ static inline void freestruct_in_a(ARGS_FREESTRUCT) { dns_rdata_in_a_t *a = source; - REQUIRE(source != NULL); + REQUIRE(a != NULL); REQUIRE(a->common.rdtype == dns_rdatatype_a); REQUIRE(a->common.rdclass == dns_rdataclass_in); diff --git a/lib/dns/rdata/in_1/aaaa_28.c b/lib/dns/rdata/in_1/aaaa_28.c index 75e5d2169a..a8c6740c31 100644 --- a/lib/dns/rdata/in_1/aaaa_28.c +++ b/lib/dns/rdata/in_1/aaaa_28.c @@ -144,7 +144,7 @@ fromstruct_in_aaaa(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_aaaa); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(aaaa != NULL); REQUIRE(aaaa->common.rdtype == type); REQUIRE(aaaa->common.rdclass == rdclass); @@ -161,7 +161,7 @@ tostruct_in_aaaa(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_aaaa); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(aaaa != NULL); REQUIRE(rdata->length == 16); UNUSED(mctx); @@ -181,7 +181,7 @@ static inline void freestruct_in_aaaa(ARGS_FREESTRUCT) { dns_rdata_in_aaaa_t *aaaa = source; - REQUIRE(source != NULL); + REQUIRE(aaaa != NULL); REQUIRE(aaaa->common.rdclass == dns_rdataclass_in); REQUIRE(aaaa->common.rdtype == dns_rdatatype_aaaa); diff --git a/lib/dns/rdata/in_1/apl_42.c b/lib/dns/rdata/in_1/apl_42.c index ae35db9b93..f376eba4c0 100644 --- a/lib/dns/rdata/in_1/apl_42.c +++ b/lib/dns/rdata/in_1/apl_42.c @@ -248,7 +248,7 @@ fromstruct_in_apl(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_apl); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(apl != NULL); REQUIRE(apl->common.rdtype == type); REQUIRE(apl->common.rdclass == rdclass); REQUIRE(apl->apl != NULL || apl->apl_len == 0); @@ -264,6 +264,7 @@ tostruct_in_apl(ARGS_TOSTRUCT) { dns_rdata_in_apl_t *apl = target; isc_region_t r; + REQUIRE(apl != NULL); REQUIRE(rdata->type == dns_rdatatype_apl); REQUIRE(rdata->rdclass == dns_rdataclass_in); @@ -286,7 +287,7 @@ static inline void freestruct_in_apl(ARGS_FREESTRUCT) { dns_rdata_in_apl_t *apl = source; - REQUIRE(source != NULL); + REQUIRE(apl != NULL); REQUIRE(apl->common.rdtype == dns_rdatatype_apl); REQUIRE(apl->common.rdclass == dns_rdataclass_in); diff --git a/lib/dns/rdata/in_1/atma_34.c b/lib/dns/rdata/in_1/atma_34.c index b5d1aa1d22..c232b3feac 100644 --- a/lib/dns/rdata/in_1/atma_34.c +++ b/lib/dns/rdata/in_1/atma_34.c @@ -201,7 +201,7 @@ fromstruct_in_atma(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_atma); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(atma != NULL); REQUIRE(atma->common.rdtype == type); REQUIRE(atma->common.rdclass == rdclass); REQUIRE(atma->atma != NULL || atma->atma_len == 0); @@ -220,7 +220,7 @@ tostruct_in_atma(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_atma); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(atma != NULL); REQUIRE(rdata->length != 0); atma->common.rdclass = rdata->rdclass; @@ -244,7 +244,7 @@ static inline void freestruct_in_atma(ARGS_FREESTRUCT) { dns_rdata_in_atma_t *atma = source; - REQUIRE(source != NULL); + REQUIRE(atma != NULL); REQUIRE(atma->common.rdclass == dns_rdataclass_in); REQUIRE(atma->common.rdtype == dns_rdatatype_atma); diff --git a/lib/dns/rdata/in_1/dhcid_49.c b/lib/dns/rdata/in_1/dhcid_49.c index 4a52d58e27..7722e466d0 100644 --- a/lib/dns/rdata/in_1/dhcid_49.c +++ b/lib/dns/rdata/in_1/dhcid_49.c @@ -121,7 +121,7 @@ fromstruct_in_dhcid(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_dhcid); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(dhcid != NULL); REQUIRE(dhcid->common.rdtype == type); REQUIRE(dhcid->common.rdclass == rdclass); REQUIRE(dhcid->length != 0); @@ -139,7 +139,7 @@ tostruct_in_dhcid(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_dhcid); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(dhcid != NULL); REQUIRE(rdata->length != 0); dhcid->common.rdclass = rdata->rdclass; diff --git a/lib/dns/rdata/in_1/eid_31.c b/lib/dns/rdata/in_1/eid_31.c index e22ac4ae7a..627d2f1e1a 100644 --- a/lib/dns/rdata/in_1/eid_31.c +++ b/lib/dns/rdata/in_1/eid_31.c @@ -112,7 +112,7 @@ fromstruct_in_eid(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_eid); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(eid != NULL); REQUIRE(eid->common.rdtype == type); REQUIRE(eid->common.rdclass == rdclass); REQUIRE(eid->eid != NULL || eid->eid_len == 0); @@ -130,7 +130,7 @@ tostruct_in_eid(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_eid); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(eid != NULL); REQUIRE(rdata->length != 0); eid->common.rdclass = rdata->rdclass; @@ -152,7 +152,7 @@ static inline void freestruct_in_eid(ARGS_FREESTRUCT) { dns_rdata_in_eid_t *eid = source; - REQUIRE(source != NULL); + REQUIRE(eid != NULL); REQUIRE(eid->common.rdclass == dns_rdataclass_in); REQUIRE(eid->common.rdtype == dns_rdatatype_eid); diff --git a/lib/dns/rdata/in_1/kx_36.c b/lib/dns/rdata/in_1/kx_36.c index 2786951de0..7431b91997 100644 --- a/lib/dns/rdata/in_1/kx_36.c +++ b/lib/dns/rdata/in_1/kx_36.c @@ -159,7 +159,7 @@ fromstruct_in_kx(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_kx); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(kx != NULL); REQUIRE(kx->common.rdtype == type); REQUIRE(kx->common.rdclass == rdclass); @@ -179,7 +179,7 @@ tostruct_in_kx(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_kx); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(kx != NULL); REQUIRE(rdata->length != 0); kx->common.rdclass = rdata->rdclass; @@ -203,7 +203,7 @@ static inline void freestruct_in_kx(ARGS_FREESTRUCT) { dns_rdata_in_kx_t *kx = source; - REQUIRE(source != NULL); + REQUIRE(kx != NULL); REQUIRE(kx->common.rdclass == dns_rdataclass_in); REQUIRE(kx->common.rdtype == dns_rdatatype_kx); diff --git a/lib/dns/rdata/in_1/nimloc_32.c b/lib/dns/rdata/in_1/nimloc_32.c index 1070a4e8c0..aba3481c57 100644 --- a/lib/dns/rdata/in_1/nimloc_32.c +++ b/lib/dns/rdata/in_1/nimloc_32.c @@ -112,7 +112,7 @@ fromstruct_in_nimloc(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_nimloc); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(nimloc != NULL); REQUIRE(nimloc->common.rdtype == type); REQUIRE(nimloc->common.rdclass == rdclass); REQUIRE(nimloc->nimloc != NULL || nimloc->nimloc_len == 0); @@ -130,7 +130,7 @@ tostruct_in_nimloc(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_nimloc); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(nimloc != NULL); REQUIRE(rdata->length != 0); nimloc->common.rdclass = rdata->rdclass; @@ -152,7 +152,7 @@ static inline void freestruct_in_nimloc(ARGS_FREESTRUCT) { dns_rdata_in_nimloc_t *nimloc = source; - REQUIRE(source != NULL); + REQUIRE(nimloc != NULL); REQUIRE(nimloc->common.rdclass == dns_rdataclass_in); REQUIRE(nimloc->common.rdtype == dns_rdatatype_nimloc); diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.c b/lib/dns/rdata/in_1/nsap-ptr_23.c index 3217300cc9..98953e4b37 100644 --- a/lib/dns/rdata/in_1/nsap-ptr_23.c +++ b/lib/dns/rdata/in_1/nsap-ptr_23.c @@ -129,7 +129,7 @@ fromstruct_in_nsap_ptr(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_nsap_ptr); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(nsap_ptr != NULL); REQUIRE(nsap_ptr->common.rdtype == type); REQUIRE(nsap_ptr->common.rdclass == rdclass); @@ -148,7 +148,7 @@ tostruct_in_nsap_ptr(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_nsap_ptr); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(nsap_ptr != NULL); REQUIRE(rdata->length != 0); nsap_ptr->common.rdclass = rdata->rdclass; @@ -168,7 +168,7 @@ static inline void freestruct_in_nsap_ptr(ARGS_FREESTRUCT) { dns_rdata_in_nsap_ptr_t *nsap_ptr = source; - REQUIRE(source != NULL); + REQUIRE(nsap_ptr != NULL); REQUIRE(nsap_ptr->common.rdclass == dns_rdataclass_in); REQUIRE(nsap_ptr->common.rdtype == dns_rdatatype_nsap_ptr); diff --git a/lib/dns/rdata/in_1/nsap_22.c b/lib/dns/rdata/in_1/nsap_22.c index ba3e69c767..c08473e17a 100644 --- a/lib/dns/rdata/in_1/nsap_22.c +++ b/lib/dns/rdata/in_1/nsap_22.c @@ -141,7 +141,7 @@ fromstruct_in_nsap(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_nsap); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(nsap != NULL); REQUIRE(nsap->common.rdtype == type); REQUIRE(nsap->common.rdclass == rdclass); REQUIRE(nsap->nsap != NULL || nsap->nsap_len == 0); @@ -159,7 +159,7 @@ tostruct_in_nsap(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_nsap); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(nsap != NULL); REQUIRE(rdata->length != 0); nsap->common.rdclass = rdata->rdclass; @@ -180,7 +180,7 @@ static inline void freestruct_in_nsap(ARGS_FREESTRUCT) { dns_rdata_in_nsap_t *nsap = source; - REQUIRE(source != NULL); + REQUIRE(nsap != NULL); REQUIRE(nsap->common.rdclass == dns_rdataclass_in); REQUIRE(nsap->common.rdtype == dns_rdatatype_nsap); diff --git a/lib/dns/rdata/in_1/px_26.c b/lib/dns/rdata/in_1/px_26.c index a94b9df0ca..bb69223f86 100644 --- a/lib/dns/rdata/in_1/px_26.c +++ b/lib/dns/rdata/in_1/px_26.c @@ -224,7 +224,7 @@ fromstruct_in_px(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_px); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(px != NULL); REQUIRE(px->common.rdtype == type); REQUIRE(px->common.rdclass == rdclass); @@ -247,7 +247,7 @@ tostruct_in_px(ARGS_TOSTRUCT) { REQUIRE(rdata->type == dns_rdatatype_px); REQUIRE(rdata->rdclass == dns_rdataclass_in); - REQUIRE(target != NULL); + REQUIRE(px != NULL); REQUIRE(rdata->length != 0); px->common.rdclass = rdata->rdclass; @@ -283,7 +283,7 @@ static inline void freestruct_in_px(ARGS_FREESTRUCT) { dns_rdata_in_px_t *px = source; - REQUIRE(source != NULL); + REQUIRE(px != NULL); REQUIRE(px->common.rdclass == dns_rdataclass_in); REQUIRE(px->common.rdtype == dns_rdatatype_px); diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c index 63a4e80a28..385bdaa049 100644 --- a/lib/dns/rdata/in_1/srv_33.c +++ b/lib/dns/rdata/in_1/srv_33.c @@ -231,7 +231,7 @@ fromstruct_in_srv(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_srv); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(srv != NULL); REQUIRE(srv->common.rdtype == type); REQUIRE(srv->common.rdclass == rdclass); @@ -253,7 +253,7 @@ tostruct_in_srv(ARGS_TOSTRUCT) { REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->type == dns_rdatatype_srv); - REQUIRE(target != NULL); + REQUIRE(srv != NULL); REQUIRE(rdata->length != 0); srv->common.rdclass = rdata->rdclass; @@ -279,7 +279,7 @@ static inline void freestruct_in_srv(ARGS_FREESTRUCT) { dns_rdata_in_srv_t *srv = source; - REQUIRE(source != NULL); + REQUIRE(srv != NULL); REQUIRE(srv->common.rdclass == dns_rdataclass_in); REQUIRE(srv->common.rdtype == dns_rdatatype_srv); diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index eabbe5bf7d..dc52eec3f5 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -296,7 +296,7 @@ fromstruct_in_wks(ARGS_FROMSTRUCT) { REQUIRE(type == dns_rdatatype_wks); REQUIRE(rdclass == dns_rdataclass_in); - REQUIRE(source != NULL); + REQUIRE(wks != NULL); REQUIRE(wks->common.rdtype == type); REQUIRE(wks->common.rdclass == rdclass); REQUIRE((wks->map != NULL && wks->map_len <= 8*1024) || @@ -317,6 +317,7 @@ tostruct_in_wks(ARGS_TOSTRUCT) { uint32_t n; isc_region_t region; + REQUIRE(wks != NULL); REQUIRE(rdata->type == dns_rdatatype_wks); REQUIRE(rdata->rdclass == dns_rdataclass_in); REQUIRE(rdata->length != 0); @@ -343,7 +344,7 @@ static inline void freestruct_in_wks(ARGS_FREESTRUCT) { dns_rdata_in_wks_t *wks = source; - REQUIRE(source != NULL); + REQUIRE(wks != NULL); REQUIRE(wks->common.rdtype == dns_rdatatype_wks); REQUIRE(wks->common.rdclass == dns_rdataclass_in); From 5fc7e98d296f2c094b11cfed68becc60a73d1594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 11:37:27 +0200 Subject: [PATCH 17/30] lib/dns/rdatalist.c: Fix dereference before DbC check --- lib/dns/rdatalist.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/dns/rdatalist.c b/lib/dns/rdatalist.c index 09b840e46b..ade3274576 100644 --- a/lib/dns/rdatalist.c +++ b/lib/dns/rdatalist.c @@ -238,14 +238,17 @@ isc_result_t isc__rdatalist_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name, dns_rdataset_t *neg, dns_rdataset_t *negsig) { - dns_rdataclass_t rdclass = rdataset->rdclass; + dns_rdataclass_t rdclass; dns_rdataset_t *tneg = NULL; dns_rdataset_t *tnegsig = NULL; - const dns_name_t *noqname = rdataset->private6; + const dns_name_t *noqname; REQUIRE(rdataset != NULL); REQUIRE((rdataset->attributes & DNS_RDATASETATTR_NOQNAME) != 0); + rdclass = rdataset->rdclass; + noqname = rdataset->private6; + (void)dns_name_dynamic(noqname); /* Sanity Check. */ for (rdataset = ISC_LIST_HEAD(noqname->list); @@ -329,14 +332,17 @@ isc_result_t isc__rdatalist_getclosest(dns_rdataset_t *rdataset, dns_name_t *name, dns_rdataset_t *neg, dns_rdataset_t *negsig) { - dns_rdataclass_t rdclass = rdataset->rdclass; + dns_rdataclass_t rdclass; dns_rdataset_t *tneg = NULL; dns_rdataset_t *tnegsig = NULL; - const dns_name_t *closest = rdataset->private7; + const dns_name_t *closest; REQUIRE(rdataset != NULL); REQUIRE((rdataset->attributes & DNS_RDATASETATTR_CLOSEST) != 0); + rdclass = rdataset->rdclass; + closest = rdataset->private7; + (void)dns_name_dynamic(closest); /* Sanity Check. */ for (rdataset = ISC_LIST_HEAD(closest->list); From 269d507cccab454bf221f03d83b6882668b41c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 11:40:00 +0200 Subject: [PATCH 18/30] Instead of declaring unused va_list, just don't declare it at all --- lib/dns/tests/dnstest.c | 3 --- lib/dns/tests/master_test.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index e1d877f59c..539e6439e7 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -475,11 +475,8 @@ dns_test_getdata(const char *file, unsigned char *buf, static void nullmsg(dns_rdatacallbacks_t *cb, const char *fmt, ...) { - va_list ap; - UNUSED(cb); UNUSED(fmt); - UNUSED(ap); } isc_result_t diff --git a/lib/dns/tests/master_test.c b/lib/dns/tests/master_test.c index 85ef0f0008..df4d078aba 100644 --- a/lib/dns/tests/master_test.c +++ b/lib/dns/tests/master_test.c @@ -63,11 +63,8 @@ _teardown(void **state) { static void nullmsg(dns_rdatacallbacks_t *cb, const char *fmt, ...) { - va_list ap; - UNUSED(cb); UNUSED(fmt); - UNUSED(ap); } #define BUFLEN 255 From 14c174d9212f0c8c9598d21e205d5d7380c54969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 11:40:44 +0200 Subject: [PATCH 19/30] lib/dns/tests/rbt_serialize_test.c: Fix dereference before DbC check --- lib/dns/tests/rbt_serialize_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dns/tests/rbt_serialize_test.c b/lib/dns/tests/rbt_serialize_test.c index 06f7006bd0..8a86d49985 100644 --- a/lib/dns/tests/rbt_serialize_test.c +++ b/lib/dns/tests/rbt_serialize_test.c @@ -170,7 +170,7 @@ write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) { static isc_result_t fix_data(dns_rbtnode_t *p, void *base, size_t max, void *arg, uint64_t *crc) { - data_holder_t *data = p->data; + data_holder_t *data; size_t size; UNUSED(base); @@ -180,6 +180,7 @@ fix_data(dns_rbtnode_t *p, void *base, size_t max, void *arg, uint64_t *crc) { REQUIRE(crc != NULL); REQUIRE(p != NULL); + data = p->data; if (data == NULL || (data->len == 0 && data->data != NULL) || From 8f2ad12d0a308a5f72f60148694976563c9a577d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 11:51:15 +0200 Subject: [PATCH 20/30] lib/dns/tsig.c: Suppress Cppcheck false positive error uninitStructMember --- lib/dns/tsig.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index fd5f61d063..38fbabba4d 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -1541,6 +1541,7 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { * XXX Can TCP transfers be forwarded? How would that * work? */ + /* cppcheck-suppress uninitStructMember symbolName=tsig.originalid */ id = htons(tsig.originalid); memmove(&header[0], &id, 2); } From e9f30fc2115524fdef638bc33beaf00a56d27b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 11:53:49 +0200 Subject: [PATCH 21/30] lib/isc/buffer.c: Fix invalid order of DbC checks that could cause dereference before NULL check --- lib/isc/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index 219a5493ab..66defe8bbb 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -550,10 +550,11 @@ isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer, bdata = isc_mem_get(mctx, length); isc_buffer_init(dbuf, bdata, length); - dbuf->mctx = mctx; ENSURE(ISC_BUFFER_VALID(dbuf)); + dbuf->mctx = mctx; + *dynbuffer = dbuf; return (ISC_R_SUCCESS); From e8948fd9b4b8b188db2d51600dc01a46d57d4b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:01:30 +0200 Subject: [PATCH 22/30] lib/isc/pkc11.c: Fix possible NULL pointer dereference in push_attribute() --- lib/isc/pk11.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/isc/pk11.c b/lib/isc/pk11.c index 6dfd51ffa2..1e7c503d8f 100644 --- a/lib/isc/pk11.c +++ b/lib/isc/pk11.c @@ -800,9 +800,13 @@ push_attribute(pk11_object_t *obj, isc_mem_t *mctx, size_t len) { CK_ATTRIBUTE *attr; CK_BYTE cnt = obj->attrcnt; + REQUIRE(old != NULL || cnt == 0); + obj->repr = isc_mem_get(mctx, (cnt + 1) * sizeof(*attr)); memset(obj->repr, 0, (cnt + 1) * sizeof(*attr)); - memmove(obj->repr, old, cnt * sizeof(*attr)); + if (old != NULL) { + memmove(obj->repr, old, cnt * sizeof(*attr)); + } attr = obj->repr + cnt; attr->ulValueLen = (CK_ULONG) len; attr->pValue = isc_mem_get(mctx, len); From c662969da190dfa186d9357b2d4454b571c2ed1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:02:41 +0200 Subject: [PATCH 23/30] lib/isc/task.c: Fix invalid order of DbC checks that could cause dereference before NULL check --- lib/isc/task.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/isc/task.c b/lib/isc/task.c index 1c44663f51..88e5fb1d83 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -1573,10 +1573,12 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) { isc_result_t isc_task_beginexclusive(isc_task_t *task0) { isc__task_t *task = (isc__task_t *)task0; - isc__taskmgr_t *manager = task->manager; + isc__taskmgr_t *manager; REQUIRE(VALID_TASK(task)); + manager = task->manager; + REQUIRE(task->state == task_state_running); LOCK(&manager->excl_lock); @@ -1605,10 +1607,13 @@ isc_task_beginexclusive(isc_task_t *task0) { void isc_task_endexclusive(isc_task_t *task0) { isc__task_t *task = (isc__task_t *)task0; - isc__taskmgr_t *manager = task->manager; + isc__taskmgr_t *manager; REQUIRE(VALID_TASK(task)); REQUIRE(task->state == task_state_running); + + manager = task->manager; + LOCK(&manager->halt_lock); REQUIRE(atomic_load_relaxed(&manager->exclusive_req) == true); atomic_store_relaxed(&manager->exclusive_req, false); From 026cf2ff4f72adfdf17d4b45496a1d3866c068ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:04:35 +0200 Subject: [PATCH 24/30] lib/isc/unix/socket.c: Suppress preprocessorErrorDirective error from Cppcheck --- lib/isc/unix/socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 5063619880..0aec560760 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -4234,6 +4234,7 @@ isc_socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) { #endif #if !defined(S_ISFIFO) && !defined(S_ISSOCK) +/* cppcheck-suppress preprocessorErrorDirective */ #error You need to define S_ISFIFO and S_ISSOCK as appropriate for your platform. See . #endif From 09232213d70c2a746f18ee0e9797883b9fe43f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:06:16 +0200 Subject: [PATCH 25/30] lib/isccfg/aclconf.c: Suppress nullPointerRedundantCheck false positive --- lib/isccfg/aclconf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index bd9d483c4d..947ac37bbd 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -138,6 +138,7 @@ convert_named_acl(const cfg_obj_t *nameobj, const cfg_obj_t *cctx, dacl != NULL; dacl = ISC_LIST_NEXT(dacl, nextincache)) { + /* cppcheck-suppress nullPointerRedundantCheck symbolName=dacl */ if (strcasecmp(aclname, dacl->name) == 0) { if (ISC_MAGIC_VALID(dacl, LOOP_MAGIC)) { cfg_obj_log(nameobj, lctx, ISC_LOG_ERROR, From f855f09a55bd7e3ba96ae42a64a81737c3c36ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:07:32 +0200 Subject: [PATCH 26/30] lib/isccfg/parser.c: Fix invalid order of DbC checks that could cause dereference before NULL check --- lib/isccfg/parser.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 699924c899..c744e296f4 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -241,7 +241,7 @@ cfg_printx(const cfg_obj_t *obj, unsigned int flags, isc_result_t cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { isc_result_t result; - const cfg_tuplefielddef_t *fields = type->of; + const cfg_tuplefielddef_t *fields; const cfg_tuplefielddef_t *f; cfg_obj_t *obj = NULL; unsigned int nfields = 0; @@ -251,6 +251,8 @@ cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { REQUIRE(type != NULL); REQUIRE(ret != NULL && *ret == NULL); + fields = type->of; + for (f = fields; f->name != NULL; f++) nfields++; @@ -272,7 +274,7 @@ isc_result_t cfg_parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { isc_result_t result; - const cfg_tuplefielddef_t *fields = type->of; + const cfg_tuplefielddef_t *fields; const cfg_tuplefielddef_t *f; cfg_obj_t *obj = NULL; unsigned int i; @@ -281,6 +283,8 @@ cfg_parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) REQUIRE(type != NULL); REQUIRE(ret != NULL && *ret == NULL); + fields = type->of; + CHECK(cfg_create_tuple(pctx, type, &obj)); for (f = fields, i = 0; f->name != NULL; f++, i++) CHECK(cfg_parse_obj(pctx, f->type, &obj->value.tuple[i])); @@ -1797,13 +1801,15 @@ cfg_parse_spacelist(cfg_parser_t *pctx, const cfg_type_t *listtype, cfg_obj_t **ret) { cfg_obj_t *listobj = NULL; - const cfg_type_t *listof = listtype->of; + const cfg_type_t *listof; isc_result_t result; REQUIRE(pctx != NULL); REQUIRE(listtype != NULL); REQUIRE(ret != NULL && *ret == NULL); + listof = listtype->of; + CHECK(cfg_create_list(pctx, listtype, &listobj)); for (;;) { @@ -1907,7 +1913,7 @@ cfg_listelt_value(const cfg_listelt_t *elt) { isc_result_t cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { - const cfg_clausedef_t * const *clausesets = type->of; + const cfg_clausedef_t * const *clausesets; isc_result_t result; const cfg_clausedef_t * const *clauseset; const cfg_clausedef_t *clause; @@ -1922,6 +1928,8 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) REQUIRE(type != NULL); REQUIRE(ret != NULL && *ret == NULL); + clausesets = type->of; + CHECK(create_map(pctx, type, &obj)); obj->value.map.clausesets = clausesets; @@ -3033,12 +3041,14 @@ cfg_print_sockaddr(cfg_printer_t *pctx, const cfg_obj_t *obj) { void cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) { - const unsigned int *flagp = type->of; + const unsigned int *flagp; int n = 0; REQUIRE(pctx != NULL); REQUIRE(type != NULL); + flagp = type->of; + cfg_print_cstr(pctx, "( "); if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); From b4a42a286fd33ef1bdc6d8b74ade12e56da3b35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:10:44 +0200 Subject: [PATCH 27/30] lib/ns/client.c: Fix invalid order of DbC checks that could cause dereference before NULL check --- lib/ns/client.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ns/client.c b/lib/ns/client.c index 034b5bbf15..f16ece8c49 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -1198,7 +1198,7 @@ client_send(ns_client_t *client) { unsigned int preferred_glue; bool opt_included = false; size_t respsize; - dns_aclenv_t *env = ns_interfacemgr_getaclenv(client->interface->mgr); + dns_aclenv_t *env; #ifdef HAVE_DNSTAP unsigned char zone[DNS_NAME_MAXWIRE]; dns_dtmsgtype_t dtmsgtype; @@ -1207,6 +1207,8 @@ client_send(ns_client_t *client) { REQUIRE(NS_CLIENT_VALID(client)); + env = ns_interfacemgr_getaclenv(client->interface->mgr); + CTRACE("send"); if (client->message->opcode == dns_opcode_query && @@ -1741,12 +1743,13 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message, unsigned int flags; unsigned char expire[4]; unsigned char advtimo[2]; - dns_aclenv_t *env = ns_interfacemgr_getaclenv(client->interface->mgr); + dns_aclenv_t *env; REQUIRE(NS_CLIENT_VALID(client)); REQUIRE(opt != NULL && *opt == NULL); REQUIRE(message != NULL); + env = ns_interfacemgr_getaclenv(client->interface->mgr); view = client->view; resolver = (view != NULL) ? view->resolver : NULL; if (resolver != NULL) @@ -3283,13 +3286,15 @@ client_newconn(isc_task_t *task, isc_event_t *event) { isc_result_t result; ns_client_t *client = event->ev_arg; isc_socket_newconnev_t *nevent = (isc_socket_newconnev_t *)event; - dns_aclenv_t *env = ns_interfacemgr_getaclenv(client->interface->mgr); + dns_aclenv_t *env; uint32_t old; REQUIRE(event->ev_type == ISC_SOCKEVENT_NEWCONN); REQUIRE(NS_CLIENT_VALID(client)); REQUIRE(client->task == task); + env = ns_interfacemgr_getaclenv(client->interface->mgr); + UNUSED(task); INSIST(client->state == NS_CLIENTSTATE_READY); From 033f3eb58046f2f1f97d434bc3e7bdc6f2c15125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:11:16 +0200 Subject: [PATCH 28/30] lib/ns/interfacemgr.c: Fix invalid order of DbC checks that could cause dereference before NULL check --- lib/ns/interfacemgr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index 923c057cee..a473d50eea 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -623,11 +623,13 @@ ns_interface_shutdown(ns_interface_t *ifp) { static void ns_interface_destroy(ns_interface_t *ifp) { - isc_mem_t *mctx = ifp->mgr->mctx; + isc_mem_t *mctx; int disp; REQUIRE(NS_INTERFACE_VALID(ifp)); + mctx = ifp->mgr->mctx; + ns_interface_shutdown(ifp); for (disp = 0; disp < ifp->nudpdispatch; disp++) From d1f035bbba57df40407a8c1dfbebc15cf42eccf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:12:14 +0200 Subject: [PATCH 29/30] lib/ns/query.c: Fix invalid order of DbC checks that could cause dereference before NULL check --- lib/ns/query.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ns/query.c b/lib/ns/query.c index 10e7af37f9..4e43b1d92c 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -10930,15 +10930,19 @@ log_queryerror(ns_client_t *client, isc_result_t result, int line, int level) { void ns_query_start(ns_client_t *client) { isc_result_t result; - dns_message_t *message = client->message; + dns_message_t *message; dns_rdataset_t *rdataset; ns_client_t *qclient; dns_rdatatype_t qtype; - unsigned int saved_extflags = client->extflags; - unsigned int saved_flags = client->message->flags; + unsigned int saved_extflags; + unsigned int saved_flags; REQUIRE(NS_CLIENT_VALID(client)); + message = client->message; + saved_extflags = client->extflags; + saved_flags = client->message->flags; + CTRACE(ISC_LOG_DEBUG(3), "ns_query_start"); /* From a0d3614a609bc9e5af39f2282daac78c40ab6363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 27 Sep 2019 12:48:23 +0200 Subject: [PATCH 30/30] Remove randomly scattered additional style check suppressions that caused unmatchedSuppression --- lib/dns/ecdb.c | 1 - lib/dns/openssldh_link.c | 2 -- lib/dns/opensslrsa_link.c | 2 -- lib/dns/rcode.c | 2 -- lib/dns/ttl.c | 1 - lib/isc/sockaddr.c | 1 - lib/isc/tests/random_test.c | 1 - lib/isc/unix/resource.c | 1 - 8 files changed, 11 deletions(-) diff --git a/lib/dns/ecdb.c b/lib/dns/ecdb.c index 6a5a2c90d2..1c258c6516 100644 --- a/lib/dns/ecdb.c +++ b/lib/dns/ecdb.c @@ -745,7 +745,6 @@ rdatasetiter_destroy(dns_rdatasetiter_t **iteratorp) { REQUIRE(iteratorp != NULL); REQUIRE(DNS_RDATASETITER_VALID(*iteratorp)); - /* cppcheck-suppress unreadVariable */ u.rdatasetiterator = *iteratorp; *iteratorp = NULL; diff --git a/lib/dns/openssldh_link.c b/lib/dns/openssldh_link.c index ff14c7e956..af6e335005 100644 --- a/lib/dns/openssldh_link.c +++ b/lib/dns/openssldh_link.c @@ -243,7 +243,6 @@ progress_cb(int p, int n, BN_GENCB *cb) { UNUSED(n); - /* cppcheck-suppress unreadVariable */ u.dptr = BN_GENCB_get_arg(cb); if (u.fptr != NULL) u.fptr(p); @@ -304,7 +303,6 @@ openssldh_generate(dst_key_t *key, int generator, void (*callback)(int)) { if (callback == NULL) { BN_GENCB_set_old(cb, NULL, NULL); } else { - /* cppcheck-suppress unreadVariable */ u.fptr = callback; BN_GENCB_set(cb, progress_cb, u.dptr); } diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index 1a61c9f366..0bd7558e5d 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -426,7 +426,6 @@ progress_cb(int p, int n, BN_GENCB *cb) { UNUSED(n); - /* cppcheck-suppress unreadVariable */ u.dptr = BN_GENCB_get_arg(cb); if (u.fptr != NULL) u.fptr(p); @@ -495,7 +494,6 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { if (callback == NULL) { BN_GENCB_set_old(cb, NULL, NULL); } else { - /* cppcheck-suppress unreadVariable */ u.fptr = callback; BN_GENCB_set(cb, progress_cb, u.dptr); } diff --git a/lib/dns/rcode.c b/lib/dns/rcode.c index 7dc51ee246..2853671d2c 100644 --- a/lib/dns/rcode.c +++ b/lib/dns/rcode.c @@ -361,7 +361,6 @@ dns_secalg_format(dns_secalg_t alg, char *cp, unsigned int size) { isc_buffer_usedregion(&b, &r); r.base[r.length] = 0; if (result != ISC_R_SUCCESS) { - /* cppcheck-suppress unreadVariable */ r.base[0] = 0; } } @@ -461,7 +460,6 @@ dns_dsdigest_format(dns_dsdigest_t typ, char *cp, unsigned int size) { isc_buffer_usedregion(&b, &r); r.base[r.length] = 0; if (result != ISC_R_SUCCESS) { - /* cppcheck-suppress unreadVariable */ r.base[0] = 0; } } diff --git a/lib/dns/ttl.c b/lib/dns/ttl.c index ee33c00440..848ab0b701 100644 --- a/lib/dns/ttl.c +++ b/lib/dns/ttl.c @@ -121,7 +121,6 @@ dns_ttl_totext(uint32_t src, bool verbose, * here because region.base is type unsigned char *. */ isc_buffer_usedregion(target, ®ion); - /* cppcheck-suppress unreadVariable */ region.base[region.length - 1] = toupper(region.base[region.length - 1]); } diff --git a/lib/isc/sockaddr.c b/lib/isc/sockaddr.c index 8dd3125aa3..832be1c2ce 100644 --- a/lib/isc/sockaddr.c +++ b/lib/isc/sockaddr.c @@ -164,7 +164,6 @@ isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) { */ isc_buffer_availableregion(target, &avail); INSIST(avail.length >= 1); - /* cppcheck-suppress unreadVariable */ avail.base[0] = '\0'; return (ISC_R_SUCCESS); diff --git a/lib/isc/tests/random_test.c b/lib/isc/tests/random_test.c index 43c499090f..556acffa4b 100644 --- a/lib/isc/tests/random_test.c +++ b/lib/isc/tests/random_test.c @@ -541,7 +541,6 @@ blockfrequency(isc_mem_t *mctx, uint16_t *values, size_t length) { /* Preconditions (section 2.2.7 in NIST SP 800-22) */ assert_true(numbits >= 100); - /* cppcheck-suppress constArgument */ assert_true(mbits >= 20); assert_true((double) mbits > (0.01 * numbits)); assert_true(numblocks < 100); diff --git a/lib/isc/unix/resource.c b/lib/isc/unix/resource.c index a00ae12565..1b8b945ef4 100644 --- a/lib/isc/unix/resource.c +++ b/lib/isc/unix/resource.c @@ -164,7 +164,6 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) { return (ISC_R_SUCCESS); } #endif - /* cppcheck-suppress duplicateCondition */ if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) { if (getrlimit(unixresource, &rl) == 0) { rl.rlim_cur = rl.rlim_max;