2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

7532 Commits

Author SHA1 Message Date
Ondřej Surý
a0d3614a60 Remove randomly scattered additional style check suppressions that caused unmatchedSuppression 2019-10-03 09:04:27 +02:00
Ondřej Surý
8f2ad12d0a lib/dns/tsig.c: Suppress Cppcheck false positive error uninitStructMember 2019-10-03 09:04:27 +02:00
Ondřej Surý
14c174d921 lib/dns/tests/rbt_serialize_test.c: Fix dereference before DbC check 2019-10-03 09:04:27 +02:00
Ondřej Surý
269d507ccc Instead of declaring unused va_list, just don't declare it at all 2019-10-03 09:04:27 +02:00
Ondřej Surý
5fc7e98d29 lib/dns/rdatalist.c: Fix dereference before DbC check 2019-10-03 09:04:26 +02:00
Ondřej Surý
66af8713d8 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);
}
2019-10-03 09:04:26 +02:00
Ondřej Surý
e68333aa67 lib/dns/rdata.c: Silence false positive nullPointerRedundantCheck warning from Cppcheck 2019-10-03 09:04:26 +02:00
Ondřej Surý
d508ce4036 lib/dns/rbtdb.c: Add DbC check to safely dereference rbtdb in rbt_datafixer() 2019-10-03 09:04:26 +02:00
Ondřej Surý
8be5c3fcfc lib/dns/rbt.c: Suppress nullPointerRedundantCheck warnings from Cppcheck 2019-10-03 09:04:26 +02:00
Ondřej Surý
0f5860aad3 lib/dns/name.c: Fix dereference before DbC check reported by Cppcheck 2019-10-03 09:04:26 +02:00
Ondřej Surý
cea871464f lib/dns/gssapi_link.c: Fix %d -> %u formatting when printing unsigned integers 2019-10-03 09:04:26 +02:00
Ondřej Surý
d8879af877 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; i<sizeof(a); i++)
        a[i] = -1;
}

int main() {
    h();
    g();
    return 0;
}
2019-10-03 09:04:26 +02:00
Ondřej Surý
91cc6b9eb9 lib/dns/ecdb.c: Fix couple of DbC conditions reported by Cppcheck 2019-10-03 09:04:26 +02:00
Ondřej Surý
fa7475b77a Fix the constification of the dns_name_t * result variable for dns_tsig_identity() 2019-10-03 09:04:26 +02:00
Ondřej Surý
2e304b0b7f Change dns_tsigkey_identity from macro to a function and const argument and result 2019-10-03 09:04:26 +02:00
Ondřej Surý
4d2697b31c Constify dns_name_t *signer argument to dns_acl_allowed() 2019-10-03 09:04:26 +02:00
Ondřej Surý
2230b9d55d Disable benchmark tests when Thread Sanitizer is enabled 2019-10-02 14:09:33 +02:00
Ondřej Surý
9b0d4f520e Convert DNS_ZONEKEY_, DNS_ZONEFLG_ and DNS_ZONELOADFLAG_ #defines to enums 2019-10-02 12:41:12 +02:00
Ondřej Surý
679ef8bb95 Fix miscelaneous zone object validity checking errors (missing REQUIRE(), out of order REQUIRE()) 2019-10-02 12:41:12 +02:00
Ondřej Surý
2638337826 Convert the flags, options, and keyopts of dns_zone_t structure to 64-bit stdatomic types
...and use atomic_fetch_or and atomic_fetch_and to set and clear the flags
2019-10-02 12:41:12 +02:00
Ondřej Surý
55a3217fe7 Convert global variables to atomic to prevent possible data race 2019-10-02 12:09:44 +02:00
Evan Hunt
488cb4da10 SERVFAIL if a prior qmin fetch has not been canceled when a new one starts 2019-10-01 20:41:53 -07:00
Ondřej Surý
288f5a4b52 Various little fixes found by coccinelle
The coccinellery repository provides many little semantic patches to fix common
problems in the code.  The number of semantic patches in the coccinellery
repository is high and most of the semantic patches apply only for Linux, so it
doesn't make sense to run them on regular basis as the processing takes a lot of
time.

The list of issue found in BIND 9, by no means complete, includes:

- double assignment to a variable
- `continue` at the end of the loop
- double checks for `NULL`
- useless checks for `NULL` (cannot be `NULL`, because of earlier return)
- using `0` instead of `NULL`
- useless extra condition (`if (foo) return; if (!foo) { ...; }`)
- removing & in front of static functions passed as arguments
2019-10-01 16:48:55 +02:00
Ondřej Surý
395741f9ad lib/dns/ssu_external.c: Use %zu for formatting sizeof() output 2019-10-01 16:24:29 +02:00
Mark Andrews
dfcc9e18cb remove unused variable 2019-10-01 12:47:26 +10:00
Ondřej Surý
69ecc711ac Move the failure handling block closer to the only place where it could fail 2019-10-01 10:43:26 +10:00
Ondřej Surý
c2dad0dcb2 Replace RUNTIME_CHECK(dns_name_copy(..., NULL)) with dns_name_copynf()
Use the semantic patch from the previous commit to replace all the calls to
dns_name_copy() with NULL as third argument with dns_name_copynf().
2019-10-01 10:43:26 +10:00
Ondřej Surý
f7aef3738a Split dns_name_copy() into dns_name_copy() and dns_name_copynf()
The dns_name_copy() function followed two different semanitcs that was driven
whether the last argument was or wasn't NULL.  This commit splits the function
in two where now third argument to dns_name_copy() can't be NULL and
dns_name_copynf() doesn't have third argument.
2019-10-01 10:43:26 +10:00
Ondřej Surý
5efa29e03a The final round of adding RUNTIME_CHECK() around dns_name_copy() calls
This commit was done by hand to add the RUNTIME_CHECK() around stray
dns_name_copy() calls with NULL as third argument.  This covers the edge cases
that doesn't make sense to write a semantic patch since the usage pattern was
unique or almost unique.
2019-10-01 10:43:26 +10:00
Ondřej Surý
89b269b0d2 Add RUNTIME_CHECK() around result = dns_name_copy(..., NULL) calls
This second commit uses second semantic patch to replace the calls to
dns_name_copy() with NULL as third argument where the result was stored in a
isc_result_t variable.  As the dns_name_copy(..., NULL) cannot fail gracefully
when the third argument is NULL, it was just a bunch of dead code.

Couple of manual tweaks (removing dead labels and unused variables) were
manually applied on top of the semantic patch.
2019-10-01 10:43:26 +10:00
Ondřej Surý
35bd7e4da0 Add RUNTIME_CHECK() around plain dns_name_copy(..., NULL) calls using spatch
This commit add RUNTIME_CHECK() around all simple dns_name_copy() calls where
the third argument is NULL using the semantic patch from the previous commit.
2019-10-01 10:43:26 +10:00
Mark Andrews
9cd308ac5e Address cut-and-paste error where list name was not changed in one instance for change 5292. 2019-09-29 10:48:59 +10:00
Michał Kępień
0476e8f1ac Make VS solution upgrading unnecessary
Until now, the build process for BIND on Windows involved upgrading the
solution file to the version of Visual Studio used on the build host.
Unfortunately, the executable used for that (devenv.exe) is not part of
Visual Studio Build Tools and thus there is no clean way to make that
executable part of a Windows Server container.

Luckily, the solution upgrade process boils down to just adding XML tags
to Visual Studio project files and modifying certain XML attributes - in
files which we pregenerate anyway using win32utils/Configure.  Thus,
extend win32utils/Configure with three new command line parameters that
enable it to mimic what "devenv.exe bind9.sln /upgrade" does.  This
makes the devenv.exe build step redundant and thus facilitates building
BIND in Windows Server containers.
2019-09-26 15:11:15 +02:00
Mark Andrews
7f30540727 prevent TSAN being trigged when DNS_RBTFIND_EMPTYDATA is set 2019-09-25 14:05:12 -04:00
Ondřej Surý
e307273307 Fix unprotected access to rbtnode in lib/dns/rbtdb.c:add32() 2019-09-25 12:29:13 +02:00
Mark Andrews
456888c00f Queue nsec3param setting until receive_secure_serial has completed. 2019-09-24 10:45:49 +10:00
Mark Andrews
9edcaa0832 Convert cache->live_tasks to reference counter. 2019-09-13 12:45:06 +10:00
Ondřej Surý
ed494fe29d Unify how we use isc_refcount_decrement() to destroy object
The isc_refcount_decrement() was either used as:

    if (isc_refcount_decrement() == 1) { destroy(); }

or

    if (isc_refcount_decrement() != 1) { return; } destroy();

This commits eradicates the last usage of the later, so the code is unified to
use the former.
2019-09-13 12:44:49 +10:00
Mark Andrews
c3bcb4d47a Remove potential use after free (fctx) in rctx_resend. 2019-09-13 12:44:12 +10:00
Mark Andrews
b125b7031c Use reference counts instead of ISC_LIST_EMPTY to determine when to destroy ecdb. 2019-09-13 12:43:52 +10:00
Michał Kępień
154f2ca6f6 Tweak lib/dns/tests/tkey_test requirements
Currently, the lib/dns/tests/tkey_test unit test is only run when the
linker supports the --wrap option.  However, linker support for that
option is only needed for static builds.  As a result, the unit test
mentioned before is not being run everywhere it can be run as even for
builds done using --with-libtool, the test is not run unless the linker
supports the --wrap option.

Tweak preprocessor directives in lib/dns/tests/tkey_test.c so that this
test is run:

  - for all builds using --with-libtool,
  - for static builds done using a linker supporting the --wrap option.
2019-09-12 14:25:57 +02:00
Michał Kępień
119f3e0c2e Make lib/dns/tests/tkey_test.c more portable
Weak symbols are handled differently by different dynamic linkers.  With
glibc, lib/dns/tests/tkey_test works as expected no matter whether
--with-libtool is used or not: __attribute__((weak)) prevents a static
build from failing and it just so happens that the desired symbols are
picked at runtime for dynamic builds.  However, with BSD libc, the
libdns functions called from lib/dns/tests/tkey_test.c use the "real"
memory allocation functions from libisc, thus breaking that unit test.
(Note: similar behavior can be reproduced with glibc by setting the
LD_DYNAMIC_WEAK environment variable.)

The simplest way to make lib/dns/tests/tkey_test work reliably is to
drop all uses of __attribute__((weak)) in it - this way, the memory
functions inside lib/dns/tests/tkey_test.c will always be used instead
of the "real" libisc ones for dynamic builds.  However, this would not
work with static builds as it would result in multiple strong symbols
with the same name being present in a single binary.

Work around the problem by only compiling in the overriding definitions
of memory functions when building using --with-libtool.  For static
builds, keep relying on the --wrap linker option for replacing calls to
the functions we are interested in.
2019-09-12 14:25:57 +02:00
Mark Andrews
b59fe46e76 address or suppress cppcheck warnings 2019-09-12 17:59:28 +10:00
Ondřej Surý
4957255d13 Use the semantic patch to change the usage isc_mem_create() to new API 2019-09-12 09:26:09 +02:00
Tinderbox User
3a1dbc13c9 prep for 9.15.4 2019-09-09 12:34:47 +00:00
Mark Andrews
3e82a2ea9a use rpzs->updater as rpz->rpzs is NULL 2019-09-05 06:47:26 +10:00
Mark Andrews
06d9e93a57 address DNS_R_MUSTBESECURE failures 2019-09-04 21:28:34 +10:00
Evan Hunt
7ba6d592ec when a response-policy zone expires, unload its polices from RPZ summary 2019-08-30 11:47:38 -07:00
Ondřej Surý
50e109d659 isc_event_allocate() cannot fail, remove the fail handling blocks
isc_event_allocate() calls isc_mem_get() to allocate the event structure.  As
isc_mem_get() cannot fail softly (e.g. it never returns NULL), the
isc_event_allocate() cannot return NULL, hence we remove the (ret == NULL)
handling blocks using the semantic patch from the previous commit.
2019-08-30 08:55:34 +02:00
Evan Hunt
6e9be9a952 use an rbtnodechain to walk up labels
when looking for a possible wildcard match in the RPZ summary database,
use an rbtnodechain to walk up label by label, rather than using the
node's parent pointer.
2019-08-29 19:37:21 -07:00