2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-28 21:17:54 +00:00

30894 Commits

Author SHA1 Message Date
Matthijs Mekking
a9a9aa7fd8 Add parentheses around return values 2020-02-06 10:17:22 +01:00
Matthijs Mekking
b378d0371f Fix kasp bug new KSK on restart [#1593]
When you do a restart or reconfig of named, or rndc loadkeys, this
triggers the key manager to run.  The key manager will check if new
keys need to be created. If there is an active key, and key rollover
is scheduled far enough away, no new key needs to be created.

However, there was a bug that when you just start to sign your zone,
it takes a while before the KSK becomes an active key. An active KSK
has its DS submitted or published, but before the key manager allows
that, the DNSKEY needs to be omnipresent. If you restart named
or rndc loadkeys in quick succession when you just started to sign
your zone, new keys will be created because the KSK is not yet
considered active.

Fix is to check for introducing as well as active keys. These keys
all have in common that their goal is to become omnipresent.
2020-02-06 10:17:22 +01:00
Matthijs Mekking
a787bc0b14 Merge branch '914-forwarders-port-documentation' into 'master'
Document forwarders config port and dscp param

Closes #914

See merge request isc-projects/bind9!2869
2020-02-06 09:00:55 +00:00
Matthijs Mekking
be3a11029a Document forwarders config port and dscp param 2020-02-06 09:23:50 +01:00
Michal Nowak
5214f24d7b Merge branch 'mnowak/windows-raise-port-range' into 'master'
Windows: Prevent tools from clashing with named in system tests

Closes #1566

See merge request isc-projects/bind9!2998
2020-02-05 10:03:10 +00:00
Michal Nowak
7f0fcb8a3e Windows: Prevent tools from clashing with named in system tests
In system tests on Windows tool's local port can sometimes clash with
'named'. On Unix the system is poked for the minimal local port,
otherwise is set to 32768 as a sane minimum. For Windows we don't
poke but set a hardcoded limit; this change aligns the limit with
Unix and changes it to 32768.
2020-02-05 10:03:09 +00:00
Mark Andrews
dd6598f391 Merge branch 'marka-coverity-master' into 'master'
Address various minor issues identified by coverity on master

See merge request isc-projects/bind9!2999
2020-02-05 08:13:16 +00:00
Mark Andrews
891f24fa57 'dispatch' must be non NULL, remove test.
10067 cleanup:

	CID 1452683 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking dispatch suggests that it
	may be null, but it has already been dereferenced on all
	paths leading to the check.

10068        if (dispatch != NULL)
10069                isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
2020-02-05 18:37:17 +11:00
Mark Andrews
fccf65a585 'dctx' must be non NULL, remove test.
1549 cleanup:
1550        if (dctx->dbiter != NULL)
1551                dns_dbiterator_destroy(&dctx->dbiter);
1552        if (dctx->db != NULL)
1553                dns_db_detach(&dctx->db);

	CID 1452686 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking dctx suggests that it may
	be null, but it has already been dereferenced on all paths
	leading to the check.

1554        if (dctx != NULL)
1555                isc_mem_put(mctx, dctx, sizeof(*dctx));
2020-02-05 18:37:17 +11:00
Mark Andrews
bf7a99a3c1 'dir_list' must be non NULL, remove test.
707 complete_allnds:

	CID 1452689 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking dir_list suggests that it
	may be null, but it has already been dereferenced on all
	paths leading to the check.

708        if (dir_list != NULL) {
709                /* clean up entries from list. */
2020-02-05 18:37:17 +11:00
Mark Andrews
7ba1af0280 'lcfg' must be non NULL, remove test.
389        else

	CID 1452695 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking lcfg suggests that it may
	be null, but it has already been dereferenced on all paths
	leading to the check.

390                if (lcfg != NULL)
391                        isc_logconfig_destroy(&lcfg);
2020-02-05 18:37:17 +11:00
Mark Andrews
714594d468 's' must be non NULL, remove test.
122 cleanup:

	CID 1452696 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking s suggests that it may be
	null, but it has already been dereferenced on all paths
	leading to the check.

123        if (s != NULL)
124                isc_mem_free(mctx, s);
2020-02-05 18:37:17 +11:00
Mark Andrews
44b08521ef 'tql' must be non NULL, remove test.
255 flag_fail:
256        /* get rid of what was build of the query list */

	CID 1452697 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking tql suggests that it may
	be null, but it has already been dereferenced on all paths
	leading to the check.

257        if (tql != NULL)
258                destroy_querylist(mctx, &tql);
2020-02-05 18:37:17 +11:00
Mark Andrews
0312e73e16 'closest' must be non NULL, remove test.
6412 cleanup:
6413        dns_rdataset_disassociate(&neg);
6414        dns_rdataset_disassociate(&negsig);

	CID 1452700 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking closest suggests that it
	may be null, but it has already been dereferenced on all
	paths leading to the check.

6415        if (closest != NULL)
6416                free_noqname(mctx, &closest);
2020-02-05 18:37:17 +11:00
Mark Andrews
d64921848d cleanup error handling.
336 cleanup_mem:
337        /* cleanup memory */
338
339        /* free tmpPath memory */

	CID 1452701 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking tmpPath suggests that it
	may be null, but it has already been dereferenced on all
	paths leading to the check.

340        if (tmpPath != NULL && result != ISC_R_SUCCESS)
341                isc_mem_free(named_g_mctx, tmpPath);
342
343        /* free tmpPath memory */
344        return (result);
2020-02-05 18:37:17 +11:00
Mark Andrews
2e189bb053 'stub' cannot be non NULL, remove test.
13429 cleanup:
13430        cancel_refresh(zone);

	CID 1452702 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking stub suggests that it may
	be null, but it has already been dereferenced on all paths
	leading to the check.

13431        if (stub != NULL) {
13432                stub->magic = 0;
2020-02-05 18:37:17 +11:00
Mark Andrews
1b1a94ea6d 'noqname' must be non NULL, remove test.
6367cleanup:
6368        dns_rdataset_disassociate(&neg);
6369        dns_rdataset_disassociate(&negsig);

	CID 1452704 (#1 of 1): Dereference before null check
	(REVERSE_INULL) check_after_deref: Null-checking noqname
	suggests that it may be null, but it has already been
	dereferenced on all paths leading to the check.

6370        if (noqname != NULL)
6371                free_noqname(mctx, &noqname);
2020-02-05 18:37:17 +11:00
Mark Andrews
8456b5627d 'dctx' must be non NULL, remove test.
11030 cleanup:

	CID 1452705 (#1 of 1): Dereference before null check
	(REVERSE_INULL) check_after_deref: Null-checking dctx
	suggests that it may be null, but it has already been
	dereferenced on all paths leading to the check.

11031        if (dctx != NULL)
11032                dumpcontext_destroy(dctx);
11033        return (result);
2020-02-05 18:37:17 +11:00
Mark Andrews
e4d08c0232 'event' must be non NULL, remove test.
1401        }

	CID 1453455 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking event suggests that it may be null,
	but it has already been dereferenced on all paths leading to the check.

1402        if (event != NULL)
1403                isc_event_free(ISC_EVENT_PTR(&event));
2020-02-05 18:37:17 +11:00
Mark Andrews
b6c3a2f172 remove dead cleanup code.
13836        if (zone != NULL)
13837                dns_zone_detach(&zone);

     	null: At condition dz != NULL, the value of dz must be NULL.
     	dead_error_condition: The condition dz != NULL cannot be true.

13838        if (dz != NULL) {

	CID 1453456 (#1 of 1): Logically dead code (DEADCODE)
	dead_error_begin: Execution cannot reach this statement:
	dns_zone_detach(&dz->zone);.

13839                dns_zone_detach(&dz->zone);
13840                isc_mem_put(named_g_mctx, dz, sizeof(*dz));
13841        }
2020-02-05 18:37:17 +11:00
Mark Andrews
1efc7550a3 keymgr_keyrole couldn't emit "NOSIGN".
92        } else {
 93                return ("ZSK");
 94        }

	CID 1455900 (#1 of 1): Structurally dead code (UNREACHABLE)
	unreachable: This code cannot be reached: return "NOSIGN";.

 95        return ("NOSIGN");
2020-02-05 18:37:17 +11:00
Mark Andrews
5fc9efba30 Remove dead error code.
128        return (ISC_R_SUCCESS);
129

	CID 1456146 (#1 of 1): Structurally dead code (UNREACHABLE)
	unreachable: This code cannot be reached: {
	   if (dst->labels[i] != N....

130        do {
2020-02-05 18:37:17 +11:00
Mark Andrews
aa101260d9 'indentctx' is always defined. Just use it.
402        ctx->serve_stale_ttl = 0;

	notnull: At condition indentctx, the value of indentctx
	cannot be NULL.  dead_error_condition: The condition indentctx
	must be true.

	CID 1456147 (#1 of 1): Logically dead code (DEADCODE)
	dead_error_line: Execution cannot reach the expression
	default_indent inside this statement: ctx->indent = (indentctx
	? ....

403        ctx->indent = indentctx ? *indentctx : default_indent;
2020-02-05 18:37:17 +11:00
Mark Andrews
0be2dc9f22 break was on wrong line.
959                break;

	CID 1457872 (#1 of 1): Structurally dead code (UNREACHABLE)
	unreachable: This code cannot be reached:
	isc__nm_incstats(sock->mgr,....

 960                isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]);
 961        default:
2020-02-05 18:37:17 +11:00
Mark Andrews
331b74d6bf dstkey is no longer used 2020-02-05 18:37:17 +11:00
Mark Andrews
a038f77d92 'buffer' must be non-NULL as isc_buffer_allocate can no longer fail.
1636 cleanup:

CID 1458130 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking buffer suggests that it may be
null, but it has already been dereferenced on all paths leading to
the check.

1637        if (buffer != NULL)
1638                isc_buffer_free(&buffer);
2020-02-05 18:37:17 +11:00
Ondřej Surý
d162bbcceb Merge branch 'ondrej/lgtm-narrow-vs-wider-type-comparison-in-a-loop' into 'master'
Fix comparison between type uint16_t and  wider type size_t in a loop

See merge request isc-projects/bind9!2986
2020-02-05 05:12:01 +00:00
Ondřej Surý
a9bd6f6ea6 Fix comparison between type uint16_t and wider type size_t in a loop
Found by LGTM.com (see below for description), and while it should not
happen as EDNS OPT RDLEN is uint16_t, the fix is easy.  A little bit
of cleanup is included too.

> In a loop condition, comparison of a value of a narrow type with a value
> of a wide type may result in unexpected behavior if the wider value is
> sufficiently large (or small). This is because the narrower value may
> overflow. This can lead to an infinite loop.
2020-02-05 01:41:13 +00:00
Matthijs Mekking
9943c5dce5 Merge branch '1192-fix-serve-stale-test' into 'master'
Resolve "Fix unreliable serve-stale test"

Closes #1192

See merge request isc-projects/bind9!2955
2020-02-04 13:15:42 +00:00
Matthijs Mekking
2c0c333d16 Increase TTL in serve-stale test
Increase the short lived record TTL and negative SOA TTL to make
this test less vulnerable to timing issues. The drawback is that we
also have to sleep longer in this test.
2020-02-04 13:35:06 +01:00
Matthijs Mekking
830d40b36e Merge branch '1183-simplify-cachedb-rrset-stats-counters' into 'master'
Simplify cachedb rrset statistic counters

Closes #1183

See merge request isc-projects/bind9!2897
2020-02-04 11:19:24 +00:00
Matthijs Mekking
7135ef78ee Add test for "Others" rrtype stat counter
Add queries and checks for CAA RRtype in the serve-stale test.
Ensure that the "Others" rrtype stat counter is incremented and
decremented properly if the RRset becomes stale/ancient.

The low max-stale-ttl config option needs to be increased in order
to match the timing when things expire (aka become ancient).
2020-02-04 11:58:34 +01:00
Matthijs Mekking
37b41ff693 Simplify cachedb rrset statistic counters
This commit simplifies the cachedb rrset statistics in two ways:
- Introduce new rdtypecounter arithmetics, allowing bitwise
  operations.
- Remove the special DLV statistic counter.

New rdtypecounter arithmetics
-----------------------------
"The rdtypecounter arithmetics is a brain twister".  Replace the
enum counters with some defines.  A rdtypecounter is now 8 bits for
RRtypes and 3 bits for flags:

      0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |  |  |  |  |  |  S  |NX|         RRType        |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

If the 8 bits for RRtype are all zero, this is an Other RRtype.

Bit 7 is the NXRRSET (NX) flag and indicates whether this is a
positive (0) or a negative (1) RRset.

Then bit 5 and 6 mostly tell you if this counter is for an active,
stale, or ancient RRtype:

    S = 0x00 means Active
    S = 0x01 means Stale
    S = 0x10 means Ancient

Since a counter cannot be stale and ancient at the same time, we
treat S = 0x11 as a special case to deal with NXDOMAIN counters.

S = 0x11 indicates an NXDOMAIN counter and in this case the RRtype
field signals the expiry of this cached item:

    RRType = 0 means Active
    RRType = 1 means Stale
    RRType = 2 means Ancient
2020-02-04 11:58:34 +01:00
Matthijs Mekking
3079956ff7 Remove the DLV statistics counter
This also removes counting the DLV RRtype separately.  Since we have
deprecated the lookaside validation it makes no sense to keep this
special statistic counter.
2020-02-04 11:58:34 +01:00
Michał Kępień
59a1e5564d Merge branch '1305-update-gitlab-ci-to-openbsd-6.6' into 'master'
Update GitLab CI to OpenBSD 6.6

Closes #1305

See merge request isc-projects/bind9!2973
2020-02-04 10:46:17 +00:00
Michał Kępień
99ed3a0e13 Update GitLab CI to OpenBSD 6.6
Since OpenBSD 6.6 is the current OpenBSD release, replace OpenBSD 6.5
GitLab CI jobs with their up-to-date counterparts.

As CI jobs for OpenBSD 6.6 will be run by a generalized libvirt executor
rather than an OpenBSD-specific one, make the necessary tag and variable
adjustments as well.
2020-02-04 11:39:27 +01:00
Ondřej Surý
a9c1fffba0 Merge branch 'cppcheck-1.90-warnings' into 'master'
Fix cppcheck 1.90 warnings

Closes #1590

See merge request isc-projects/bind9!2969
2020-02-04 10:10:48 +00:00
Matthijs Mekking
b8be29fee6 Add a note on memory allocation
isc__memalloc_t must deal with memory allocation failure
and must never return NULL.
2020-02-04 11:09:22 +01:00
Ondřej Surý
2868eafc46 Suppress unknownMacro directive which is currently broken with OpenSSL 2020-02-04 11:09:22 +01:00
Ondřej Surý
c00def343f Suppress cppcheck false positive nullPointerArithmeticRedundantCheck 2020-02-04 11:09:22 +01:00
Ondřej Surý
05ae2e48ab Change pk11_mem_get() so it cannot soft-fail 2020-02-04 11:09:22 +01:00
Ondřej Surý
478e4ac201 Make the DbC checks to be consistent and cppcheck clean 2020-02-04 11:09:22 +01:00
Mark Andrews
bb65e57297 isc_mem_get cannot fail 2020-02-04 11:09:22 +01:00
Mark Andrews
d6de520bd1 delay assignment until after REQUIRE 2020-02-04 11:09:22 +01:00
Mark Andrews
704b9ee9d0 skip if first is NULL 2020-02-04 11:09:22 +01:00
Mark Andrews
c65c06301c delay assignment until after REQUIRE 2020-02-04 11:09:22 +01:00
Mark Andrews
f17b9b8dd1 make expression logical for cppcheck 2020-02-04 11:09:22 +01:00
Mark Andrews
7b948c7335 remove brackets 2020-02-04 11:09:22 +01:00
Mark Andrews
6c2e138d7a simplify ISC_LIKELY/ISC_UNLIKELY for CPPCHECK 2020-02-04 11:09:22 +01:00
Mark Andrews
668a972d1e simplify RUNTIME_CHECK for cppcheck 2020-02-04 11:09:22 +01:00