From 4345905a81f683b98d2b356e05032cb2f2ce072b Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 9 Dec 2016 12:57:47 +0100 Subject: [PATCH] Address things that came out of VS static analysis Except for the stack usage cases --- src/context.c | 2 +- src/dnssec.c | 8 ++++++++ src/extension/default_eventloop.c | 2 +- src/list.c | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/context.c b/src/context.c index 7fcca880..7d542c45 100644 --- a/src/context.c +++ b/src/context.c @@ -419,7 +419,7 @@ sockaddr_dict(getdns_context *context, struct sockaddr *sa) break; port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port); - if (port != GETDNS_PORT_DNS && port != GETDNS_PORT_DNS && + if (port != GETDNS_PORT_ZERO && port != GETDNS_PORT_DNS && getdns_dict_set_int(address, "port", (uint32_t)port)) break; diff --git a/src/dnssec.c b/src/dnssec.c index 2312a286..51d566f2 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -616,6 +616,11 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf, head->node_count = node_count; if (!node_count) { + /* When this head has no nodes of itself, it must have found + * another head which has nodes for its labels (i.e. max_head) + */ + assert(max_head != NULL); + head->parent = max_head->parent; return head; } @@ -1090,6 +1095,9 @@ static void val_chain_node_soa_cb(getdns_dns_req *dnsreq) _getdns_rrset *rrset; _getdns_context_clear_outbound_request(dnsreq); + /* A SOA query is always scheduled with a node as the user argument. + */ + assert(node != NULL); for ( i = _getdns_rrset_iter_init(&i_spc, netreq->response , netreq->response_len diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index ce010bc0..c27dacde 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -126,7 +126,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event) DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNCTION__, loop, event); i = (intptr_t)event->ev - 1; - if (i < 0 || i > FD_SETSIZE) { + if (i < 0 || i >= FD_SETSIZE) { return GETDNS_RETURN_GENERIC_ERROR; } if (event->timeout_cb && !event->read_cb && !event->write_cb) { diff --git a/src/list.c b/src/list.c index 4a73b63f..7a7d3e38 100644 --- a/src/list.c +++ b/src/list.c @@ -353,6 +353,9 @@ _getdns_list_copy(const struct getdns_list * srclist, retval = _getdns_list_append_dict(*dstlist, srclist->items[i].data.dict); break; + default: + retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED; + break; } if (retval != GETDNS_RETURN_GOOD) { getdns_list_destroy(*dstlist);