Commit 49849155 authored by Evan Hunt's avatar Evan Hunt
Browse files

Merge branch '171-lgtm-issues' into 'master'

Resolve "problems detected by LGTM static analyzer"

Closes #171

See merge request !213
parents 44721442 8b1baa10
Pipeline #1343 passed with stages
in 6 minutes and 51 seconds
......@@ -287,12 +287,12 @@ received(unsigned int bytes, isc_sockaddr_t *from, dig_query_t *query) {
} else {
printf(";; MSG SIZE rcvd: %u\n", bytes);
}
if (key != NULL) {
if (tsigkey != NULL) {
if (!validated)
puts(";; WARNING -- Some TSIG could not "
"be validated");
}
if ((key == NULL) && (keysecret[0] != 0)) {
if ((tsigkey == NULL) && (keysecret[0] != 0)) {
puts(";; WARNING -- TSIG key was not used.");
}
puts("");
......
......@@ -176,7 +176,7 @@ unsigned char cookie[8];
const dns_name_t *hmacname = NULL;
unsigned int digestbits = 0;
isc_buffer_t *namebuf = NULL;
dns_tsigkey_t *key = NULL;
dns_tsigkey_t *tsigkey = NULL;
isc_boolean_t validated = ISC_TRUE;
isc_entropy_t *entp = NULL;
isc_mempool_t *commctx = NULL;
......@@ -905,13 +905,13 @@ setup_text_key(void) {
result = dns_tsigkey_create(&keyname, hmacname, secretstore,
(int)secretsize, ISC_FALSE, NULL, 0, 0,
mctx, NULL, &key);
mctx, NULL, &tsigkey);
failure:
if (result != ISC_R_SUCCESS)
printf(";; Couldn't create key %s: %s\n",
keynametext, isc_result_totext(result));
else
dst_key_setbits(key->key, digestbits);
dst_key_setbits(tsigkey->key, digestbits);
isc_mem_free(mctx, secretstore);
dns_name_invalidate(&keyname);
......@@ -1198,7 +1198,7 @@ setup_file_key(void) {
}
result = dns_tsigkey_createfromkey(dst_key_name(dstkey), hmacname,
dstkey, ISC_FALSE, NULL, 0, 0,
mctx, NULL, &key);
mctx, NULL, &tsigkey);
if (result != ISC_R_SUCCESS) {
printf(";; Couldn't create key %s: %s\n",
keynametext, isc_result_totext(result));
......@@ -2286,9 +2286,9 @@ setup_lookup(dig_lookup_t *lookup) {
/* XXX Insist this? */
lookup->tsigctx = NULL;
lookup->querysig = NULL;
if (key != NULL) {
if (tsigkey != NULL) {
debug("initializing keys");
result = dns_message_settsigkey(lookup->sendmsg, key);
result = dns_message_settsigkey(lookup->sendmsg, tsigkey);
check_result(result, "dns_message_settsigkey");
}
......@@ -3653,7 +3653,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
check_result(result, "dns_message_create");
if (key != NULL) {
if (tsigkey != NULL) {
if (l->querysig == NULL) {
debug("getting initial querysig");
result = dns_message_getquerytsig(l->sendmsg, mctx,
......@@ -3662,7 +3662,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
}
result = dns_message_setquerytsig(msg, l->querysig);
check_result(result, "dns_message_setquerytsig");
result = dns_message_settsigkey(msg, key);
result = dns_message_settsigkey(msg, tsigkey);
check_result(result, "dns_message_settsigkey");
msg->tsigctx = l->tsigctx;
l->tsigctx = NULL;
......@@ -3838,7 +3838,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
}
}
if (key != NULL) {
if (tsigkey != NULL) {
result = dns_tsig_verify(&query->recvbuf, msg, NULL, NULL);
if (result != ISC_R_SUCCESS) {
printf(";; Couldn't verify signature: %s\n",
......@@ -4205,9 +4205,9 @@ destroy_libs(void) {
debug("freeing timermgr");
isc_timermgr_destroy(&timermgr);
}
if (key != NULL) {
debug("freeing key %p", key);
dns_tsigkey_detach(&key);
if (tsigkey != NULL) {
debug("freeing key %p", tsigkey);
dns_tsigkey_detach(&tsigkey);
}
if (namebuf != NULL)
isc_buffer_free(&namebuf);
......
......@@ -259,7 +259,7 @@ extern char keyfile[MXNAME];
extern char keysecret[MXNAME];
extern const dns_name_t *hmacname;
extern unsigned int digestbits;
extern dns_tsigkey_t *key;
extern dns_tsigkey_t *tsigkey;
extern isc_boolean_t validated;
extern isc_taskmgr_t *taskmgr;
extern isc_task_t *global_task;
......
......@@ -492,13 +492,13 @@ cleanup:
*/
static void
add_opt(dns_message_t *msg, isc_uint16_t udpsize, isc_uint16_t edns,
unsigned int flags, dns_ednsopt_t *ednsopts, size_t count)
unsigned int flags, dns_ednsopt_t *opts, size_t count)
{
dns_rdataset_t *rdataset = NULL;
isc_result_t result;
result = dns_message_buildopt(msg, &rdataset, edns, udpsize, flags,
ednsopts, count);
opts, count);
CHECK("dns_message_buildopt", result);
result = dns_message_setopt(msg, rdataset);
CHECK("dns_message_setopt", result);
......
#ifndef BIND_KEYS_H
#define BIND_KEYS_H 1
#define TRUSTED_KEYS "\
# The bind.keys file is used to override the built-in DNSSEC trust anchors\n\
# which are included as part of BIND 9. The only trust anchors it contains\n\
......@@ -103,3 +105,4 @@ managed-keys {\n\
R1AkUTV74bU=\";\n\
};\n\
"
#endif /* BIND_KEYS_H */
......@@ -9,8 +9,6 @@
* information regarding copyright ownership.
*/
/* $Id: portlist.h,v 1.9 2007/06/19 23:47:17 tbox Exp $ */
/*! \file dns/portlist.h */
#include <isc/lang.h>
......@@ -19,6 +17,9 @@
#include <dns/types.h>
#ifndef DNS_PORTLIST_H
#define DNS_PORTLIST_H 1
ISC_LANG_BEGINDECLS
isc_result_t
......@@ -93,3 +94,5 @@ dns_portlist_detach(dns_portlist_t **portlistp);
*/
ISC_LANG_ENDDECLS
#endif /* DNS_PORTLIST_H */
......@@ -9,10 +9,11 @@
* information regarding copyright ownership.
*/
/* $Id: version.h,v 1.9.1234.1 2012/02/11 22:37:57 each Exp $ */
/*! \file dns/version.h */
#ifndef DNS_VERSION_H
#define DNS_VERSION_H 1
#include <isc/platform.h>
LIBDNS_EXTERNAL_DATA extern const char dns_version[];
......@@ -22,3 +23,5 @@ LIBDNS_EXTERNAL_DATA extern const char dns_mapapi[];
LIBDNS_EXTERNAL_DATA extern const unsigned int dns_libinterface;
LIBDNS_EXTERNAL_DATA extern const unsigned int dns_librevision;
LIBDNS_EXTERNAL_DATA extern const unsigned int dns_libage;
#endif /* DNS_VERSION_H */
......@@ -9,8 +9,6 @@
* information regarding copyright ownership.
*/
/* $Id$ */
/*! \file */
#include <config.h>
......@@ -1340,8 +1338,9 @@ load_text(dns_loadctx_t *lctx) {
if (MANYERRS(lctx, result)) {
SETRESULT(lctx, result);
lctx->ttl = 0;
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
} else if (!explicit_ttl &&
lctx->default_ttl_known) {
lctx->ttl = lctx->default_ttl;
......@@ -1372,8 +1371,9 @@ load_text(dns_loadctx_t *lctx) {
result = DNS_R_SYNTAX;
if (MANYERRS(lctx, result)) {
SETRESULT(lctx, result);
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
}
/*
......@@ -1544,8 +1544,9 @@ load_text(dns_loadctx_t *lctx) {
SETRESULT(lctx, result);
LOGIT(result);
continue;
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
}
/*
......@@ -1584,8 +1585,9 @@ load_text(dns_loadctx_t *lctx) {
SETRESULT(lctx, result);
read_till_eol = ISC_TRUE;
continue;
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
}
if (ictx->origin_changed) {
......@@ -1628,8 +1630,9 @@ load_text(dns_loadctx_t *lctx) {
SETRESULT(lctx, result);
read_till_eol = ISC_TRUE;
continue;
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
}
if (rdclass == 0 &&
......@@ -1646,8 +1649,9 @@ load_text(dns_loadctx_t *lctx) {
SETRESULT(lctx, result);
read_till_eol = ISC_TRUE;
continue;
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
}
result = dns_rdatatype_fromtext(&type,
......@@ -1687,8 +1691,9 @@ load_text(dns_loadctx_t *lctx) {
SETRESULT(lctx, result);
read_till_eol = ISC_TRUE;
continue;
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
}
if (type == dns_rdatatype_ns && ictx->glue == NULL)
......@@ -1800,8 +1805,9 @@ load_text(dns_loadctx_t *lctx) {
namebuf, desc);
if (MANYERRS(lctx, result)) {
SETRESULT(lctx, result);
} else if (result != ISC_R_SUCCESS)
} else {
goto cleanup;
}
} else {
(*callbacks->warn)(callbacks,
"%s:%lu: %s: %s",
......@@ -1852,8 +1858,9 @@ load_text(dns_loadctx_t *lctx) {
read_till_eol = ISC_TRUE;
target = target_ft;
continue;
} else if (result != ISC_R_SUCCESS)
} else {
goto insist_and_cleanup;
}
}
if (type == dns_rdatatype_rrsig ||
......
......@@ -9,8 +9,6 @@
* information regarding copyright ownership.
*/
/* $Id$ */
/*! \file */
#include <config.h>
......@@ -1410,7 +1408,7 @@ rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target) {
source->private5 = tempdb;
}
static dns_rdatasetmethods_t methods = {
static dns_rdatasetmethods_t sdb_rdataset_methods = {
disassociate,
isc__rdatalist_first,
isc__rdatalist_next,
......@@ -1445,7 +1443,7 @@ list_tordataset(dns_rdatalist_t *rdatalist,
RUNTIME_CHECK(dns_rdatalist_tordataset(rdatalist, rdataset) ==
ISC_R_SUCCESS);
rdataset->methods = &methods;
rdataset->methods = &sdb_rdataset_methods;
dns_db_attachnode(db, node, &rdataset->private5);
}
......
......@@ -865,20 +865,20 @@ der_get_octet_string(const unsigned char *p, size_t len,
}
static int
der_get_oid(const unsigned char *p, size_t len,
oid *data, size_t *size)
{
der_get_oid(const unsigned char *p, size_t len, oid *data, size_t *size) {
int n;
size_t oldlen = len;
data->components = NULL;
data->length = 0;
if (len < 1U)
if (len < 1U) {
return (ASN1_OVERRUN);
}
data->components = malloc(len * sizeof(*data->components));
if (data->components == NULL && len != 0U)
if (data->components == NULL) {
return (ENOMEM);
}
data->components[0] = (*p) / 40;
data->components[1] = (*p) % 40;
--len;
......@@ -897,8 +897,9 @@ der_get_oid(const unsigned char *p, size_t len,
return (ASN1_OVERRUN);
}
data->length = n;
if (size)
if (size) {
*size = oldlen;
}
return (0);
}
......
......@@ -9,10 +9,8 @@
* information regarding copyright ownership.
*/
/* $Id: dnsconf.h,v 1.3 2009/09/02 23:48:03 tbox Exp $ */
#ifndef ISCCFG_NAMEDCONF_H
#define ISCCFG_NAMEDCONF_H 1
#ifndef ISCCFG_DNSCONF_H
#define ISCCFG_DNSCONF_H 1
/*! \file
* \brief
......@@ -27,4 +25,4 @@
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_dnsconf;
/*%< A complete dns.conf file. */
#endif /* ISCCFG_CFG_H */
#endif /* ISCCFG_DNSCONF_H */
......@@ -9,8 +9,6 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
# $Id: bindkeys.pl,v 1.7 2011/01/04 23:47:13 tbox Exp $
use strict;
use warnings;
......@@ -31,6 +29,9 @@ $lines =~ s/managed-keys/trusted-keys/;
$lines =~ s/\s+initial-key//g;
my $tkey = '#define TRUSTED_KEYS "\\' . "\n" . $lines . "\"\n";
print "#ifndef BIND_KEYS_H\n";
print "#define BIND_KEYS_H 1\n";
print $tkey;
print "\n";
print $mkey;
print "#endif /* BIND_KEYS_H */\n";
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