Commit d23b8915 authored by Ondřej Surý's avatar Ondřej Surý

Merge branch '45-integrate-llvm-scan-build-to-gitlab-ci-workflow-v9_11' into 'v9_11'

Resolve "Integrate LLVM scan-build to GitLab CI workflow"

See merge request !2522
parents add1c6cb 178f2f84
Pipeline #24907 passed with stages
in 1 minute and 56 seconds
......@@ -16,6 +16,8 @@ variables:
TEST_PARALLEL_JOBS: 6
MAKE: make
CONFIGURE: ./configure
SCAN_BUILD: scan-build-9
stages:
- precheck
......@@ -88,7 +90,7 @@ stages:
.debian-buster-amd64: &debian_buster_amd64_image
image: "$CI_REGISTRY_IMAGE:debian-buster-amd64"
<<: *linux_i386
<<: *linux_amd64
.debian-sid-amd64: &debian_sid_amd64_image
image: "$CI_REGISTRY_IMAGE:debian-sid-amd64"
......@@ -158,7 +160,7 @@ stages:
expire_in: "1 week"
.configure: &configure |
./configure \
${CONFIGURE} \
--disable-maintainer-mode \
--enable-developer \
--with-randomdev=/dev/urandom \
......@@ -506,6 +508,38 @@ unit:gcc:buster:amd64:
- gcc:buster:amd64
needs: ["gcc:buster:amd64"]
# Jobs for scan-build builds on Debian Buster (amd64)
.scan_build: &scan_build |
${SCAN_BUILD} --html-title="BIND 9 ($CI_COMMIT_SHORT_SHA)" \
--keep-cc \
--status-bugs \
--keep-going \
-o scan-build.reports \
make -j${BUILD_PARALLEL_JOBS:-1} all V=1
scan-build:buster:amd64:
<<: *default_triggering_rules
<<: *debian_buster_amd64_image
stage: postcheck
variables:
CC: clang-9
CFLAGS: "-Wall -Wextra -O2 -g"
CONFIGURE: "${SCAN_BUILD} ./configure"
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2"
script:
- *configure
- *scan_build
dependencies:
- autoreconf:sid:amd64
needs:
- autoreconf:sid:amd64
artifacts:
paths:
- scan-build.reports/
expire_in: "1 week"
when: on_failure
# Jobs for regular GCC builds on Debian Sid (amd64)
gcc:sid:amd64:
......
......@@ -792,7 +792,10 @@ hashlist_comp(const void *a, const void *b) {
static void
hashlist_sort(hashlist_t *l) {
qsort(l->hashbuf, l->entries, l->length, hashlist_comp);
INSIST(l->hashbuf != NULL || l->length == 0);
if (l->length > 0) {
qsort(l->hashbuf, l->entries, l->length, hashlist_comp);
}
}
static bool
......
......@@ -150,14 +150,6 @@ EXTERN const char * lwresd_g_defaultpidfile INIT(NS_LOCALSTATEDIR
"/run/lwresd.pid");
#endif
#ifdef HAVE_DNSTAP
EXTERN const char * ns_g_defaultdnstap
INIT(NS_LOCALSTATEDIR "/run/named/"
"dnstap.sock");
#else
EXTERN const char * ns_g_defaultdnstap INIT(NULL);
#endif /* HAVE_DNSTAP */
EXTERN const char * ns_g_username INIT(NULL);
#if defined(USE_PKCS11)
......
......@@ -3050,7 +3050,7 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
isc_result_t result;
const cfg_obj_t *obj, *obj2;
const cfg_listelt_t *element;
const char *dpath = ns_g_defaultdnstap;
const char *dpath;
const cfg_obj_t *dlist = NULL;
dns_dtmsgtype_t dttypes = 0;
dns_dtmode_t dmode;
......@@ -7555,6 +7555,7 @@ load_configuration(const char *filename, ns_server_t *server,
INSIST(result == ISC_R_SUCCESS);
CHECKM(setstring(server, &server->bindkeysfile,
cfg_obj_asstring(obj)), "strdup");
INSIST(server->bindkeysfile != NULL);
if (access(server->bindkeysfile, R_OK) == 0) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
......
......@@ -63,7 +63,6 @@ ns_paths_init(void) {
ns_g_defaultlockfile = isc_ntpaths_get(NAMED_LOCK_PATH);
ns_g_keyfile = isc_ntpaths_get(RNDC_KEY_PATH);
ns_g_defaultsessionkeyfile = isc_ntpaths_get(SESSION_KEY_PATH);
ns_g_defaultdnstap = NULL;
Initialized = TRUE;
}
......
......@@ -151,12 +151,11 @@ query(void) {
dns_fixedname_t name;
dns_fixedname_t found;
dns_db_t *db;
char *s;
isc_buffer_t buffer;
isc_result_t result;
dns_rdataset_t rdataset;
dns_rdataset_t sigset;
fd_set rfdset;
fd_set rfdset = { { 0 } };
db = NULL;
result = dns_zone_getdb(zone, &db);
......@@ -171,7 +170,7 @@ query(void) {
dns_rdataset_init(&sigset);
do {
char *s;
fprintf(stdout, "zone_test ");
fflush(stdout);
FD_ZERO(&rfdset);
......
......@@ -109,6 +109,7 @@ add_name(struct dlz_example_data *state, struct record *list,
int first_empty = -1;
for (i = 0; i < MAX_RECORDS; i++) {
INSIST(list[i].name != NULL);
if (first_empty == -1 && strlen(list[i].name) == 0U) {
first_empty = i;
}
......
......@@ -953,21 +953,12 @@ client_resfind(resctx_t *rctx, dns_fetchevent_t *event) {
* Otherwise, get some resource for copying the
* result.
*/
dns_name_t *aname = dns_fixedname_name(&rctx->name);
ansname = isc_mem_get(mctx, sizeof(*ansname));
if (ansname == NULL)
tresult = ISC_R_NOMEMORY;
else {
dns_name_t *aname;
aname = dns_fixedname_name(&rctx->name);
dns_name_init(ansname, NULL);
tresult = dns_name_dup(aname, mctx, ansname);
if (tresult != ISC_R_SUCCESS)
isc_mem_put(mctx, ansname,
sizeof(*ansname));
}
if (tresult != ISC_R_SUCCESS)
result = tresult;
dns_name_init(ansname, NULL);
(void)dns_name_dup(aname, mctx, ansname);
}
switch (result) {
......
......@@ -167,6 +167,7 @@ send_test(void **state) {
cleanup();
result = dns_test_makeview("test", &view);
assert_int_equal(result, ISC_R_SUCCESS);
fopt = fstrm_iothr_options_init();
assert_non_null(fopt);
......@@ -190,6 +191,7 @@ send_test(void **state) {
memset(&zr, 0, sizeof(zr));
isc_buffer_init(&zb, zone, sizeof(zone));
result = dns_compress_init(&cctx, -1, mctx);
assert_int_equal(result, ISC_R_SUCCESS);
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
result = dns_name_towire(zname, &cctx, &zb);
assert_int_equal(result, ISC_R_SUCCESS);
......
......@@ -903,7 +903,7 @@ remove_nodes(dns_rbt_t *mytree, char **names,
UNUSED(mytree);
for (i = 0; i < num_names; i++) {
for (i = 0; i < num_names && *names_count > 0; i++) {
uint32_t node;
dns_fixedname_t fname;
dns_name_t *name;
......@@ -920,11 +920,10 @@ remove_nodes(dns_rbt_t *mytree, char **names,
assert_int_equal(result, ISC_R_SUCCESS);
isc_mem_free(mctx, names[node]);
if (*names_count > 0) {
names[node] = names[*names_count - 1];
names[*names_count - 1] = NULL;
*names_count -= 1;
}
names[node] = names[*names_count - 1];
names[*names_count - 1] = NULL;
*names_count -= 1;
}
}
......
......@@ -926,6 +926,7 @@ dns_tsig_sign(dns_message_t *msg) {
unsigned char header[DNS_MESSAGE_HEADERLEN];
isc_buffer_t headerbuf;
uint16_t digestbits;
bool querytsig_ok = false;
/*
* If it is a response, we assume that the request MAC
......@@ -972,14 +973,8 @@ dns_tsig_sign(dns_message_t *msg) {
ret = dst_context_adddata(ctx, &r);
if (ret != ISC_R_SUCCESS)
goto cleanup_context;
querytsig_ok = true;
}
#if defined(__clang__) && \
( __clang_major__ < 3 || \
(__clang_major__ == 3 && __clang_minor__ < 2) || \
(__clang_major__ == 4 && __clang_minor__ < 2))
/* false positive: http://llvm.org/bugs/show_bug.cgi?id=14461 */
else memset(&querytsig, 0, sizeof(querytsig));
#endif
/*
* Digest the header.
......@@ -1025,8 +1020,7 @@ dns_tsig_sign(dns_message_t *msg) {
}
/* Digest the timesigned and fudge */
isc_buffer_clear(&databuf);
if (tsig.error == dns_tsigerror_badtime) {
INSIST(response);
if (tsig.error == dns_tsigerror_badtime && querytsig_ok) {
tsig.timesigned = querytsig.timesigned;
}
isc_buffer_putuint48(&databuf, tsig.timesigned);
......@@ -1077,19 +1071,8 @@ dns_tsig_sign(dns_message_t *msg) {
dst_context_destroy(&ctx);
digestbits = dst_key_getbits(key->key);
if (digestbits != 0) {
/*
* XXXRAY: Is this correct? What is the
* expected behavior when digestbits is not an
* integral multiple of 8? It looks like bytes
* should either be (digestbits/8) or
* (digestbits+7)/8.
*
* In any case, for current algorithms,
* digestbits are an integral multiple of 8, so
* it has the same effect as (digestbits/8).
*/
unsigned int bytes = (digestbits + 1) / 8;
if (response && bytes < querytsig.siglen)
unsigned int bytes = (digestbits + 7) / 8;
if (querytsig_ok && bytes < querytsig.siglen)
bytes = querytsig.siglen;
if (bytes > isc_buffer_usedlength(&sigbuf))
bytes = isc_buffer_usedlength(&sigbuf);
......@@ -1482,18 +1465,8 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
{
uint16_t digestbits = dst_key_getbits(key);
/*
* XXXRAY: Is this correct? What is the expected
* behavior when digestbits is not an integral multiple
* of 8? It looks like bytes should either be
* (digestbits/8) or (digestbits+7)/8.
*
* In any case, for current algorithms, digestbits are
* an integral multiple of 8, so it has the same effect
* as (digestbits/8).
*/
if (tsig.siglen > 0 && digestbits != 0 &&
tsig.siglen < ((digestbits + 1) / 8))
tsig.siglen < ((digestbits + 7) / 8))
{
msg->tsigstatus = dns_tsigerror_badtrunc;
tsig_log(msg->tsigkey, 2,
......@@ -1805,19 +1778,8 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) {
{
uint16_t digestbits = dst_key_getbits(key);
/*
* XXXRAY: Is this correct? What is the
* expected behavior when digestbits is not an
* integral multiple of 8? It looks like bytes
* should either be (digestbits/8) or
* (digestbits+7)/8.
*
* In any case, for current algorithms,
* digestbits are an integral multiple of 8, so
* it has the same effect as (digestbits/8).
*/
if (tsig.siglen > 0 && digestbits != 0 &&
tsig.siglen < ((digestbits + 1) / 8))
tsig.siglen < ((digestbits + 7) / 8))
{
msg->tsigstatus = dns_tsigerror_badtrunc;
tsig_log(msg->tsigkey, 2,
......
......@@ -322,7 +322,7 @@ asyncload(dns_zone_t *zone, void *paramsv) {
isc_result_t result;
struct zt_load_params * params = (struct zt_load_params*) paramsv;
dns_zt_t *zt = params->zt;
dns_zt_t *zt;
REQUIRE(zone != NULL);
zt = dns_zone_getview(zone)->zonetable;
......
......@@ -402,8 +402,8 @@ lwres_context_recv(lwres_context_t *ctx,
int *recvd_len)
{
LWRES_SOCKADDR_LEN_T fromlen;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
struct sockaddr_in sin = { .sin_port = 0 };
struct sockaddr_in6 sin6 = { .sin6_port = 0 };
struct sockaddr *sa;
int ret;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment