bind9/bin/tests/optional
Ondřej Surý 0fdc09efb6 Fix 'Dereference of null pointer' from scan-build-10
These are mostly false positives, the clang-analyzer FAQ[1] specifies
why and how to fix it:

> The reason the analyzer often thinks that a pointer can be null is
> because the preceding code checked compared it against null. So if you
> are absolutely sure that it cannot be null, remove the preceding check
> and, preferably, add an assertion as well.

The 4 warnings reported are:

dnssec-cds.c:781:4: warning: Access to field 'base' results in a dereference of a null pointer (loaded from variable 'buf')
                        isc_buffer_availableregion(buf, &r);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/builds/isc-projects/bind9/lib/isc/include/isc/buffer.h:996:36: note: expanded from macro 'isc_buffer_availableregion'
                                   ^
/builds/isc-projects/bind9/lib/isc/include/isc/buffer.h:821:16: note: expanded from macro 'ISC__BUFFER_AVAILABLEREGION'
                (_r)->base = isc_buffer_used(_b);              \
                             ^~~~~~~~~~~~~~~~~~~
/builds/isc-projects/bind9/lib/isc/include/isc/buffer.h:152:29: note: expanded from macro 'isc_buffer_used'
        ((void *)((unsigned char *)(b)->base + (b)->used)) /*d*/
                                   ^~~~~~~~~
1 warning generated.

--

byname_test.c:308:34: warning: Access to field 'fwdtable' results in a dereference of a null pointer (loaded from variable 'view')
                RUNTIME_CHECK(dns_fwdtable_add(view->fwdtable, dns_rootname,
                                               ^~~~~~~~~~~~~~
/builds/isc-projects/bind9/lib/isc/include/isc/util.h:318:52: note: expanded from macro 'RUNTIME_CHECK'
                                                   ^~~~
/builds/isc-projects/bind9/lib/isc/include/isc/error.h:50:21: note: expanded from macro 'ISC_ERROR_RUNTIMECHECK'
        ((void)(ISC_LIKELY(cond) ||  \
                           ^~~~
/builds/isc-projects/bind9/lib/isc/include/isc/likely.h:23:43: note: expanded from macro 'ISC_LIKELY'
                                            ^
1 warning generated.

--

./rndc.c:255:6: warning: Dereference of null pointer (loaded from variable 'host')
        if (*host == '/') {
            ^~~~~
1 warning generated.

--

./main.c:1254:9: warning: Access to field 'sctx' results in a dereference of a null pointer (loaded from variable 'named_g_server')
        sctx = named_g_server->sctx;
               ^~~~~~~~~~~~~~~~~~~~
1 warning generated.

References:
1. https://clang-analyzer.llvm.org/faq.html#null_pointer

(cherry picked from commit ddd0d356e5)
2020-03-25 18:06:29 +01:00
..
.gitignore Add backtrace_test and nsecify to bin/tests/optional/.gitignore 2018-05-31 12:06:51 +02:00
adb_test.c Refactor the isc_log API so it cannot fail on memory failures 2020-03-18 11:44:18 +01:00
backtrace_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
byaddr_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
byname_test.c Fix 'Dereference of null pointer' from scan-build-10 2020-03-25 18:06:29 +01:00
db_test.c Refactor the isc_log API so it cannot fail on memory failures 2020-03-18 11:44:18 +01:00
fsaccess_test.c Use the new sorting rules to regroup #include headers 2020-03-11 08:55:12 +00:00
gsstest.c Refactor the isc_log API so it cannot fail on memory failures 2020-03-18 11:44:18 +01:00
inter_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
Kchild.example.+005+33180.key Convert the bin/tests/optional/sig0_test.c to use RSASHA1 instead of DSA 2018-10-26 11:50:11 +02:00
Kchild.example.+005+33180.private Convert the bin/tests/optional/sig0_test.c to use RSASHA1 instead of DSA 2018-10-26 11:50:11 +02:00
lex_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
lfsr_test.c fix spelling errors reported by Fossies. 2020-02-21 07:05:31 +00:00
log_test.c Refactor the isc_log API so it cannot fail on memory failures 2020-03-18 11:44:18 +01:00
Makefile.in Add ZLIB_LIBS to ISCLIBS 2020-02-28 15:22:59 +01:00
master_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
mempool_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
name_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
nsecify.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
ratelimiter_test.c Merge branch '46-enforce-clang-format-rules' into 'master' 2020-02-14 08:45:59 +00:00
rbt_test.c fix spelling errors reported by Fossies. 2020-02-21 07:05:31 +00:00
rbt_test.out move all optional tests from bin/tests to bin/tests/optional 2018-03-09 14:12:47 -08:00
rbt_test.txt move all optional tests from bin/tests to bin/tests/optional 2018-03-09 14:12:47 -08:00
rwlock_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
serial_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
shutdown_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
sig0_test.c Refactor the isc_log API so it cannot fail on memory failures 2020-03-18 11:44:18 +01:00
sock_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
sym_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
task_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
timer_test.c Merge branch 'each-style-tweak' into 'master' 2020-02-14 05:35:29 +00:00
zone_test.c Use the new sorting rules to regroup #include headers 2020-03-11 08:55:12 +00:00