3390. [bug] Silence clang compiler warnings. [RT #30417]

This commit is contained in:
Mark Andrews 2012-10-06 12:26:50 +10:00
parent d0e2f6c6ca
commit e4e82b398c
18 changed files with 258 additions and 161 deletions

View file

@ -1,3 +1,5 @@
3390. [bug] Silence clang compiler warnings. [RT #30417]
3389. [bug] Always return NOERROR (not 0) in TSIG. [RT #31275]
3388. [bug] Fixed several Coverity warnings. [RT #30996]

View file

@ -2415,7 +2415,7 @@ send_udp(dig_query_t *query) {
static void
connect_timeout(isc_task_t *task, isc_event_t *event) {
dig_lookup_t *l = NULL;
dig_query_t *query = NULL, *cq;
dig_query_t *query = NULL, *next, *cq;
UNUSED(task);
REQUIRE(event->ev_type == ISC_TIMEREVENT_IDLE);
@ -2439,7 +2439,9 @@ connect_timeout(isc_task_t *task, isc_event_t *event) {
if (query->sock != NULL)
isc_socket_cancel(query->sock, NULL,
ISC_SOCKCANCEL_ALL);
send_tcp_connect(ISC_LIST_NEXT(cq, link));
next = ISC_LIST_NEXT(cq, link);
if (next != NULL)
send_tcp_connect(next);
}
UNLOCK_LOOKUP;
return;
@ -3417,15 +3419,19 @@ getaddresses(dig_lookup_t *lookup, const char *host, isc_result_t *resultp) {
*/
void
do_lookup(dig_lookup_t *lookup) {
dig_query_t *query;
REQUIRE(lookup != NULL);
debug("do_lookup()");
lookup->pending = ISC_TRUE;
if (lookup->tcp_mode)
send_tcp_connect(ISC_LIST_HEAD(lookup->q));
else
send_udp(ISC_LIST_HEAD(lookup->q));
query = ISC_LIST_HEAD(lookup->q);
if (query != NULL) {
if (lookup->tcp_mode)
send_tcp_connect(query);
else
send_udp(query);
}
}
/*%

View file

@ -2390,6 +2390,9 @@ ns_client_replace(ns_client_t *client) {
CTRACE("replace");
REQUIRE(client != NULL);
REQUIRE(client->manager != NULL);
result = ns_clientmgr_createclients(client->manager,
1, client->interface,
(TCP_CLIENT(client) ?

View file

@ -61,7 +61,7 @@ command_compare(const char *text, const char *command) {
isc_result_t
ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
isccc_sexpr_t *data;
char *command;
char *command = NULL;
isc_result_t result;
int log_level;
#ifdef HAVE_LIBSCF

View file

@ -9,4 +9,4 @@
# cishm is 0 if a case insensitive hash of testname1 should match a
# case insensitive hash of testname2, otherwise cishm != 0
#
a.b.c.d a.b.c.d. 0 0
a.b.c.d A.B.C.D 0 1

View file

@ -25,8 +25,10 @@
#include <isc/buffer.h>
#include <isc/mem.h>
#include <isc/string.h>
#include <isc/util.h>
#include <dns/compress.h>
#include <dns/fixedname.h>
#include <dns/name.h>
#include <dns/result.h>
@ -38,6 +40,39 @@
static char *Tokens[MAXTOKS + 1];
#define BINDABLE(name) \
((name->attributes & (DNS_NAMEATTR_READONLY|DNS_NAMEATTR_DYNAMIC)) \
== 0)
static isc_result_t
dns_name_fromstring2(dns_name_t *target, const char *src,
const dns_name_t *origin, unsigned int options,
isc_mem_t *mctx)
{
isc_result_t result;
isc_buffer_t buf;
dns_fixedname_t fn;
dns_name_t *name;
REQUIRE(src != NULL);
isc_buffer_init(&buf, src, strlen(src));
isc_buffer_add(&buf, strlen(src));
if (BINDABLE(target) && target->buffer != NULL)
name = target;
else {
dns_fixedname_init(&fn);
name = dns_fixedname_name(&fn);
}
result = dns_name_fromtext(name, &buf, origin, options, NULL);
if (result != ISC_R_SUCCESS)
return (result);
if (name != target)
result = dns_name_dupwithoffsets(name, mctx, target);
return (result);
}
#ifdef NEED_PBUF
@ -166,7 +201,7 @@ chkdata(unsigned char *buf, size_t buflen, char *exp_data,
else {
t_info("bad data at position %lu, "
"got 0x%.2x, expected 0x%.2x\n",
(unsigned long)cnt, *p, *q);
(unsigned long)cnt, *p, *v);
result = cnt + 1;
}
(void)free(data);
@ -330,41 +365,6 @@ hname_to_tname(char *src, char *target, size_t len) {
#endif /* NEED_HNAME_TO_TNAME */
/*%
* initialize a dns_name_t from a text name, hiding all
* buffer and other object initialization from the caller
*
*/
static isc_result_t
dname_from_tname(char *name, dns_name_t *dns_name) {
int len;
isc_buffer_t txtbuf;
isc_buffer_t *binbuf;
unsigned char *junk;
isc_result_t result;
len = strlen(name);
isc_buffer_init(&txtbuf, name, len);
isc_buffer_add(&txtbuf, len);
junk = (unsigned char *)malloc(sizeof(unsigned char) * BUFLEN);
binbuf = (isc_buffer_t *)malloc(sizeof(isc_buffer_t));
if ((junk != NULL) && (binbuf != NULL)) {
isc_buffer_init(binbuf, junk, BUFLEN);
dns_name_init(dns_name, NULL);
dns_name_setbuffer(dns_name, binbuf);
result = dns_name_fromtext(dns_name, &txtbuf,
NULL, ISC_FALSE, NULL);
} else {
result = ISC_R_NOSPACE;
if (junk != NULL)
(void)free(junk);
if (binbuf != NULL)
(void)free(binbuf);
}
return (result);
}
static const char *a3 = "dns_name_init initializes 'name' to the empty name";
static void
@ -625,8 +625,10 @@ test_dns_name_hash(char *test_name1, char *test_name2,
isc_boolean_t match;
unsigned int hash1;
unsigned int hash2;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_fixedname_t fixed1;
dns_fixedname_t fixed2;
dns_name_t *dns_name1;
dns_name_t *dns_name2;
isc_result_t result;
rval = T_UNRESOLVED;
@ -634,12 +636,17 @@ test_dns_name_hash(char *test_name1, char *test_name2,
t_info("testing names %s and %s\n", test_name1, test_name2);
result = dname_from_tname(test_name1, &dns_name1);
dns_fixedname_init(&fixed1);
dns_fixedname_init(&fixed2);
dns_name1 = dns_fixedname_name(&fixed1);
dns_name2 = dns_fixedname_name(&fixed2);
result = dns_name_fromstring2(dns_name1, test_name1, NULL, 0, NULL);
if (result == ISC_R_SUCCESS) {
result = dname_from_tname(test_name2, &dns_name2);
result = dns_name_fromstring2(dns_name2, test_name2, NULL,
0, NULL);
if (result == ISC_R_SUCCESS) {
hash1 = dns_name_hash(&dns_name1, ISC_TRUE);
hash2 = dns_name_hash(&dns_name2, ISC_TRUE);
hash1 = dns_name_hash(dns_name1, ISC_TRUE);
hash2 = dns_name_hash(dns_name2, ISC_TRUE);
match = ISC_FALSE;
if (hash1 == hash2)
match = ISC_TRUE;
@ -647,8 +654,8 @@ test_dns_name_hash(char *test_name1, char *test_name2,
++failures;
t_info("hash mismatch when ISC_TRUE\n");
}
hash1 = dns_name_hash(&dns_name1, ISC_FALSE);
hash2 = dns_name_hash(&dns_name2, ISC_FALSE);
hash1 = dns_name_hash(dns_name1, ISC_FALSE);
hash2 = dns_name_hash(dns_name2, ISC_FALSE);
match = ISC_FALSE;
if (hash1 == hash2)
match = ISC_TRUE;
@ -661,11 +668,11 @@ test_dns_name_hash(char *test_name1, char *test_name2,
else
rval = T_FAIL;
} else {
t_info("dns_fromtext %s failed, result = %s\n",
t_info("dns_name_fromstring2 %s failed, result = %s\n",
test_name2, dns_result_totext(result));
}
} else {
t_info("dns_fromtext %s failed, result = %s\n",
t_info("dns_name_fromstring2 %s failed, result = %s\n",
test_name1, dns_result_totext(result));
}
return (rval);
@ -767,8 +774,10 @@ test_dns_name_fullcompare(char *name1, char *name2,
int nfails;
int order;
unsigned int nlabels;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_fixedname_t fixed1;
dns_fixedname_t fixed2;
dns_name_t *dns_name1;
dns_name_t *dns_name2;
isc_result_t dns_result;
dns_namereln_t dns_reln;
@ -779,11 +788,16 @@ test_dns_name_fullcompare(char *name1, char *name2,
t_info("testing names %s and %s for relation %s\n", name1, name2,
dns_namereln_to_text(exp_dns_reln));
dns_result = dname_from_tname(name1, &dns_name1);
dns_fixedname_init(&fixed1);
dns_fixedname_init(&fixed2);
dns_name1 = dns_fixedname_name(&fixed1);
dns_name2 = dns_fixedname_name(&fixed2);
dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_result = dname_from_tname(name2, &dns_name2);
dns_result = dns_name_fromstring2(dns_name2, name2, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_reln = dns_name_fullcompare(&dns_name1, &dns_name2,
dns_reln = dns_name_fullcompare(dns_name1, dns_name2,
&order, &nlabels);
if (dns_reln != exp_dns_reln) {
@ -815,11 +829,11 @@ test_dns_name_fullcompare(char *name1, char *name2,
else
result = T_FAIL;
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
@ -908,8 +922,10 @@ test_dns_name_compare(char *name1, char *name2, int exp_order) {
int result;
int order;
isc_result_t dns_result;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_fixedname_t fixed1;
dns_fixedname_t fixed2;
dns_name_t *dns_name1;
dns_name_t *dns_name2;
result = T_UNRESOLVED;
@ -917,11 +933,16 @@ test_dns_name_compare(char *name1, char *name2, int exp_order) {
exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"),
name2);
dns_result = dname_from_tname(name1, &dns_name1);
dns_fixedname_init(&fixed1);
dns_fixedname_init(&fixed2);
dns_name1 = dns_fixedname_name(&fixed1);
dns_name2 = dns_fixedname_name(&fixed2);
dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_result = dname_from_tname(name2, &dns_name2);
dns_result = dns_name_fromstring2(dns_name2, name2, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
order = dns_name_compare(&dns_name1, &dns_name2);
order = dns_name_compare(dns_name1, dns_name2);
/*
* Normalize order.
*/
@ -936,11 +957,11 @@ test_dns_name_compare(char *name1, char *name2, int exp_order) {
} else
result = T_PASS;
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
@ -1011,19 +1032,26 @@ test_dns_name_rdatacompare(char *name1, char *name2, int exp_order) {
int result;
int order;
isc_result_t dns_result;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_fixedname_t fixed1;
dns_fixedname_t fixed2;
dns_name_t *dns_name1;
dns_name_t *dns_name2;
result = T_UNRESOLVED;
t_info("testing %s %s %s\n", name1,
exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"), name2);
dns_result = dname_from_tname(name1, &dns_name1);
dns_fixedname_init(&fixed1);
dns_fixedname_init(&fixed2);
dns_name1 = dns_fixedname_name(&fixed1);
dns_name2 = dns_fixedname_name(&fixed2);
dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_result = dname_from_tname(name2, &dns_name2);
dns_result = dns_name_fromstring2(dns_name2, name2, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
order = dns_name_rdatacompare(&dns_name1, &dns_name2);
order = dns_name_rdatacompare(dns_name1, dns_name2);
/*
* Normalize order.
*/
@ -1038,11 +1066,11 @@ test_dns_name_rdatacompare(char *name1, char *name2, int exp_order) {
} else
result = T_PASS;
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
@ -1114,19 +1142,26 @@ test_dns_name_issubdomain(char *name1, char *name2, isc_boolean_t exp_rval) {
int result;
isc_boolean_t rval;
isc_result_t dns_result;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_fixedname_t fixed1;
dns_fixedname_t fixed2;
dns_name_t *dns_name1;
dns_name_t *dns_name2;
result = T_UNRESOLVED;
t_info("testing %s %s a subdomain of %s\n", name1,
exp_rval == 0 ? "is not" : "is", name2);
dns_result = dname_from_tname(name1, &dns_name1);
dns_fixedname_init(&fixed1);
dns_fixedname_init(&fixed2);
dns_name1 = dns_fixedname_name(&fixed1);
dns_name2 = dns_fixedname_name(&fixed2);
dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_result = dname_from_tname(name2, &dns_name2);
dns_result = dns_name_fromstring2(dns_name2, name2, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
rval = dns_name_issubdomain(&dns_name1, &dns_name2);
rval = dns_name_issubdomain(dns_name1, dns_name2);
if (rval != exp_rval) {
t_info("expected return value of %s, got %s\n",
@ -1136,11 +1171,11 @@ test_dns_name_issubdomain(char *name1, char *name2, isc_boolean_t exp_rval) {
} else
result = T_PASS;
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
@ -1207,15 +1242,18 @@ test_dns_name_countlabels(char *test_name, unsigned int exp_nlabels) {
int result;
unsigned int nlabels;
isc_result_t dns_result;
dns_name_t dns_name;
dns_fixedname_t fixed;
dns_name_t *dns_name;
result = T_UNRESOLVED;
t_info("testing %s\n", test_name);
dns_result = dname_from_tname(test_name, &dns_name);
dns_fixedname_init(&fixed);
dns_name = dns_fixedname_name(&fixed);
dns_result = dns_name_fromstring2(dns_name, test_name, NULL, 0, NULL);
if (dns_result == ISC_R_SUCCESS) {
nlabels = dns_name_countlabels(&dns_name);
nlabels = dns_name_countlabels(dns_name);
if (nlabels != exp_nlabels) {
t_info("expected %d, got %d\n", exp_nlabels, nlabels);
@ -1223,7 +1261,7 @@ test_dns_name_countlabels(char *test_name, unsigned int exp_nlabels) {
} else
result = T_PASS;
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(dns_result));
}
@ -1297,8 +1335,10 @@ test_dns_name_getlabel(char *test_name1, int label1_pos, char *test_name2,
unsigned int cnt;
unsigned char *p;
unsigned char *q;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_fixedname_t fixed1;
dns_fixedname_t fixed2;
dns_name_t *dns_name1;
dns_name_t *dns_name2;
dns_label_t dns_label1;
dns_label_t dns_label2;
isc_result_t dns_result;
@ -1308,12 +1348,18 @@ test_dns_name_getlabel(char *test_name1, int label1_pos, char *test_name2,
t_info("testing with %s and %s\n", test_name1, test_name2);
dns_result = dname_from_tname(test_name1, &dns_name1);
dns_fixedname_init(&fixed1);
dns_fixedname_init(&fixed2);
dns_name1 = dns_fixedname_name(&fixed1);
dns_name2 = dns_fixedname_name(&fixed2);
dns_result = dns_name_fromstring2(dns_name1, test_name1, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_result = dname_from_tname(test_name2, &dns_name2);
dns_result = dns_name_fromstring2(dns_name2, test_name2, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_name_getlabel(&dns_name1, label1_pos, &dns_label1);
dns_name_getlabel(&dns_name2, label2_pos, &dns_label2);
dns_name_getlabel(dns_name1, label1_pos, &dns_label1);
dns_name_getlabel(dns_name2, label2_pos, &dns_label2);
if (dns_label1.length != dns_label2.length) {
t_info("label lengths differ\n");
++nfails;
@ -1332,11 +1378,11 @@ test_dns_name_getlabel(char *test_name1, int label1_pos, char *test_name2,
else
result = T_FAIL;
} else {
t_info("dname_from_tname failed, result == %s",
t_info("dns_name_fromstring2 failed, result == %s",
dns_result_totext(result));
}
} else {
t_info("dname_from_tname failed, result == %s",
t_info("dns_name_fromstring2 failed, result == %s",
dns_result_totext(result));
}
return (result);
@ -1410,8 +1456,10 @@ test_dns_name_getlabelsequence(char *test_name1, int label1_start,
unsigned int cnt;
unsigned char *p;
unsigned char *q;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_fixedname_t fixed1;
dns_fixedname_t fixed2;
dns_name_t *dns_name1;
dns_name_t *dns_name2;
dns_name_t dns_targetname1;
dns_name_t dns_targetname2;
isc_result_t dns_result;
@ -1422,16 +1470,22 @@ test_dns_name_getlabelsequence(char *test_name1, int label1_start,
nfails = 0;
result = T_UNRESOLVED;
dns_result = dname_from_tname(test_name1, &dns_name1);
dns_fixedname_init(&fixed1);
dns_fixedname_init(&fixed2);
dns_name1 = dns_fixedname_name(&fixed1);
dns_name2 = dns_fixedname_name(&fixed2);
dns_result = dns_name_fromstring2(dns_name1, test_name1, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_result = dname_from_tname(test_name2, &dns_name2);
dns_result = dns_name_fromstring2(dns_name2, test_name2, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
t_info("testing %s %s\n", test_name1, test_name2);
dns_name_init(&dns_targetname1, NULL);
dns_name_init(&dns_targetname2, NULL);
dns_name_getlabelsequence(&dns_name1, label1_start,
dns_name_getlabelsequence(dns_name1, label1_start,
range, &dns_targetname1);
dns_name_getlabelsequence(&dns_name2, label2_start,
dns_name_getlabelsequence(dns_name2, label2_start,
range, &dns_targetname2);
/*
@ -1462,11 +1516,11 @@ test_dns_name_getlabelsequence(char *test_name1, int label1_start,
else
result = T_FAIL;
} else {
t_info("dname_from_tname failed, result == %s",
t_info("dns_name_fromstring2 failed, result == %s",
dns_result_totext(dns_result));
}
} else {
t_info("dname_from_tname failed, result == %s",
t_info("dns_name_fromstring2 failed, result == %s",
dns_result_totext(dns_result));
}
return (result);
@ -1533,7 +1587,8 @@ test_dns_name_fromregion(char *test_name) {
int order;
unsigned int nlabels;
isc_result_t dns_result;
dns_name_t dns_name1;
dns_fixedname_t fixed1;
dns_name_t *dns_name1;
dns_name_t dns_name2;
dns_namereln_t dns_namereln;
isc_region_t region;
@ -1542,21 +1597,23 @@ test_dns_name_fromregion(char *test_name) {
t_info("testing %s\n", test_name);
dns_result = dname_from_tname(test_name, &dns_name1);
dns_fixedname_init(&fixed1);
dns_name1 = dns_fixedname_name(&fixed1);
dns_result = dns_name_fromstring2(dns_name1, test_name, NULL, 0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_name_toregion(&dns_name1, &region);
dns_name_toregion(dns_name1, &region);
dns_name_init(&dns_name2, NULL);
dns_name_fromregion(&dns_name2, &region);
dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2,
dns_namereln = dns_name_fullcompare(dns_name1, &dns_name2,
&order, &nlabels);
if (dns_namereln == dns_namereln_equal)
result = T_PASS;
else
result = T_FAIL;
} else {
t_info("dname_from_tname failed, result == %s\n",
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(result));
}
return (result);
@ -1985,8 +2042,9 @@ test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase,
char buf2[BUFLEN];
isc_buffer_t iscbuf1;
isc_buffer_t iscbuf2;
dns_fixedname_t fixed2;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_name_t *dns_name2;
isc_result_t dns_result;
dns_namereln_t dns_namereln;
dns_decompress_t dctx;
@ -2007,10 +2065,13 @@ test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase,
if ((dns_result == exp_result) && (exp_result == ISC_R_SUCCESS)) {
dns_result = dname_from_tname(exp_name, &dns_name2);
dns_fixedname_init(&fixed2);
dns_name2 = dns_fixedname_name(&fixed2);
dns_result = dns_name_fromstring2(dns_name2, exp_name, NULL,
0, NULL);
if (dns_result == ISC_R_SUCCESS) {
dns_namereln = dns_name_fullcompare(&dns_name1,
&dns_name2,
dns_name2,
&order, &nlabels);
if (dns_namereln != dns_namereln_equal) {
t_info("dns_name_fullcompare returned %s\n",

View file

@ -1056,6 +1056,12 @@ t_dns_rbtnodechain_first(char *dbfile, char *expected_firstname,
dns_fixedname_t dns_origin;
isc_result_t expected_result;
REQUIRE(dbfile != NULL);
REQUIRE(expected_firstname != NULL);
REQUIRE(expected_firstorigin != NULL);
REQUIRE(expected_nextname != NULL);
REQUIRE(expected_nextorigin != NULL);
result = T_UNRESOLVED;
nfails = 0;
@ -1247,6 +1253,12 @@ t_dns_rbtnodechain_last(char *dbfile, char *expected_lastname,
dns_fixedname_t dns_origin;
isc_result_t expected_result;
REQUIRE(dbfile != NULL);
REQUIRE(expected_lastname != NULL);
REQUIRE(expected_lastorigin != NULL);
REQUIRE(expected_prevname != NULL);
REQUIRE(expected_prevorigin != NULL);
result = T_UNRESOLVED;
nfails = 0;

View file

@ -400,7 +400,7 @@ test_gethostbyaddr(const char *address, int af, const char *name) {
return;
}
} else {
if (strcmp(hp->h_name, name) != 0) {
if (name != NULL && strcmp(hp->h_name, name) != 0) {
printf("I:gethostbyname(%s) returned %s, "
"expected %s\n", address, hp->h_name, name);
fails++;
@ -440,7 +440,7 @@ test_getipnodebyaddr(const char *address, int af, const char *name) {
return;
}
} else {
if (strcmp(hp->h_name, name) != 0) {
if (name != NULL && strcmp(hp->h_name, name) != 0) {
printf("I:getipnodebyaddr(%s) returned %s, "
"expected %s\n", address, hp->h_name, name);
freehostent(hp);

View file

@ -314,22 +314,18 @@ sdlzh_build_querystring(isc_mem_t *mctx, query_list_t *querylist)
if (qs == NULL)
return NULL;
*qs = 0;
/* start at the top of the list again */
tseg = ISC_LIST_HEAD(*querylist);
/* copy the first item in the list to the query string */
if (tseg->direct == isc_boolean_true) /* query segment */
strcpy(qs, tseg->sql);
else
strcpy(qs, * (char**) tseg->sql); /* dynamic segment */
/* concatonate the rest of the segments */
while ((tseg = ISC_LIST_NEXT(tseg, link)) != NULL) {
while (tseg != NULL) {
if (tseg->direct == isc_boolean_true)
/* query segments */
strcat(qs, tseg->sql);
else
/* dynamic segments */
strcat(qs, * (char**) tseg->sql);
/* get the next segment */
tseg = ISC_LIST_NEXT(tseg, link);
}
return qs;

View file

@ -1243,15 +1243,17 @@ ISC_LANG_ENDDECLS
#define DNS_NAME_INIT(n, o) \
do { \
(n)->magic = DNS_NAME_MAGIC; \
(n)->ndata = NULL; \
(n)->length = 0; \
(n)->labels = 0; \
(n)->attributes = 0; \
(n)->offsets = (o); \
(n)->buffer = NULL; \
ISC_LINK_INIT((n), link); \
ISC_LIST_INIT((n)->list); \
dns_name_t *_n = (n); \
/* memset(_n, 0, sizeof(*_n)); */ \
_n->magic = DNS_NAME_MAGIC; \
_n->ndata = NULL; \
_n->length = 0; \
_n->labels = 0; \
_n->attributes = 0; \
_n->offsets = (o); \
_n->buffer = NULL; \
ISC_LINK_INIT(_n, link); \
ISC_LIST_INIT(_n->list); \
} while (0)
#define DNS_NAME_RESET(n) \

View file

@ -583,11 +583,13 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
nlabels = 0;
l1 = name1->labels;
l2 = name2->labels;
ldiff = (int)l1 - (int)l2;
if (ldiff < 0)
if (l2 > l1) {
l = l1;
else
ldiff = 0 - (l2 - l1);
} else {
l = l2;
ldiff = l1 - l2;
}
while (l > 0) {
l--;
@ -2240,6 +2242,7 @@ dns_name_digest(dns_name_t *name, dns_digestfunc_t digest, void *arg) {
REQUIRE(digest != NULL);
DNS_NAME_INIT(&downname, NULL);
isc_buffer_init(&buffer, data, sizeof(data));
result = dns_name_downcase(name, &downname, &buffer);

View file

@ -5966,7 +5966,8 @@ addnoqname(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
cleanup:
dns_rdataset_disassociate(&neg);
dns_rdataset_disassociate(&negsig);
free_noqname(mctx, &noqname);
if (noqname != NULL)
free_noqname(mctx, &noqname);
return(result);
}

View file

@ -846,10 +846,13 @@ der_get_octet_string(const unsigned char *p, size_t len,
octet_string *data, size_t *size)
{
data->length = len;
data->data = malloc(len);
if (data->data == NULL && data->length != 0U)
return (ENOMEM);
memcpy(data->data, p, len);
if (len != 0) {
data->data = malloc(len);
if (data->data == NULL)
return (ENOMEM);
memcpy(data->data, p, len);
} else
data->data = NULL;
if (size)
*size = len;
return (0);

View file

@ -45,6 +45,7 @@ ATF_TC_BODY(parse_overflow, tc) {
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_parse_uint32(&output, "1234567890", 10);
ATF_CHECK_EQ(ISC_R_SUCCESS, result);
ATF_CHECK_EQ(1234567890, output);
result = isc_parse_uint32(&output, "123456789012345", 10);

View file

@ -610,7 +610,7 @@ isc_result_t
isccc_cc_createresponse(isccc_sexpr_t *message, isccc_time_t now,
isccc_time_t expires, isccc_sexpr_t **alistp)
{
char *_frm, *_to, *type;
char *_frm, *_to, *type = NULL;
isc_uint32_t serial;
isccc_sexpr_t *alist, *_ctrl, *_data;
isc_result_t result;
@ -700,6 +700,8 @@ isccc_cc_lookupstring(isccc_sexpr_t *alist, const char *key, char **strp)
{
isccc_sexpr_t *kv, *v;
REQUIRE(strp == NULL || *strp == NULL);
kv = isccc_alist_assq(alist, key);
if (kv != NULL) {
v = ISCCC_SEXPR_CDR(kv);
@ -798,7 +800,7 @@ isccc_cc_checkdup(isccc_symtab_t *symtab, isccc_sexpr_t *message,
{
const char *_frm;
const char *_to;
char *_ser, *_tim, *tmp;
char *_ser = NULL, *_tim = NULL, *tmp;
isc_result_t result;
char *key;
size_t len;
@ -810,13 +812,19 @@ isccc_cc_checkdup(isccc_symtab_t *symtab, isccc_sexpr_t *message,
isccc_cc_lookupstring(_ctrl, "_ser", &_ser) != ISC_R_SUCCESS ||
isccc_cc_lookupstring(_ctrl, "_tim", &_tim) != ISC_R_SUCCESS)
return (ISC_R_FAILURE);
INSIST(_ser != NULL);
INSIST(_tim != NULL);
/*
* _frm and _to are optional.
*/
tmp = NULL;
if (isccc_cc_lookupstring(_ctrl, "_frm", &tmp) != ISC_R_SUCCESS)
_frm = "";
else
_frm = tmp;
tmp = NULL;
if (isccc_cc_lookupstring(_ctrl, "_to", &tmp) != ISC_R_SUCCESS)
_to = "";
else

View file

@ -573,10 +573,8 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip,
(void) lwres_conf_parse(lwrctx, lwres_resolv_conf);
if (hostname == NULL && (flags & AI_PASSIVE) == 0) {
ai = ai_clone(*aip, AF_INET);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
if (ai == NULL)
SETERROR(EAI_MEMORY);
}
*aip = ai;
ai->ai_socktype = socktype;
@ -594,10 +592,8 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip,
addr = LWRES_LIST_HEAD(by->addrs);
while (addr != NULL) {
ai = ai_clone(*aip, AF_INET);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
if (ai == NULL)
SETERROR(EAI_MEMORY);
}
*aip = ai;
ai->ai_socktype = socktype;
SIN(ai->ai_addr)->sin_port = port;
@ -641,10 +637,8 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
if (hostname == NULL && (flags & AI_PASSIVE) == 0) {
ai = ai_clone(*aip, AF_INET6);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
if (ai == NULL)
SETERROR(EAI_MEMORY);
}
*aip = ai;
ai->ai_socktype = socktype;
@ -662,10 +656,8 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
addr = LWRES_LIST_HEAD(by->addrs);
while (addr != NULL) {
ai = ai_clone(*aip, AF_INET6);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
if (ai == NULL)
SETERROR(EAI_MEMORY);
}
*aip = ai;
ai->ai_socktype = socktype;
SIN6(ai->ai_addr)->sin6_port = port;

View file

@ -466,6 +466,9 @@ lwres_freehostent(struct hostent *he) {
int names = 1;
int addresses = 1;
if (he == NULL)
return;
free(he->h_name);
cpp = he->h_addr_list;

View file

@ -271,18 +271,22 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass,
void
lwres_freerrset(struct rrsetinfo *rrset) {
unsigned int i;
for (i = 0; i < rrset->rri_nrdatas; i++) {
if (rrset->rri_rdatas[i].rdi_data == NULL)
break;
free(rrset->rri_rdatas[i].rdi_data);
if (rrset->rri_rdatas != NULL) {
for (i = 0; i < rrset->rri_nrdatas; i++) {
if (rrset->rri_rdatas[i].rdi_data == NULL)
break;
free(rrset->rri_rdatas[i].rdi_data);
}
free(rrset->rri_rdatas);
}
free(rrset->rri_rdatas);
for (i = 0; i < rrset->rri_nsigs; i++) {
if (rrset->rri_sigs[i].rdi_data == NULL)
break;
free(rrset->rri_sigs[i].rdi_data);
if (rrset->rri_sigs != NULL) {
for (i = 0; i < rrset->rri_nsigs; i++) {
if (rrset->rri_sigs[i].rdi_data == NULL)
break;
free(rrset->rri_sigs[i].rdi_data);
}
free(rrset->rri_sigs);
}
free(rrset->rri_sigs);
free(rrset->rri_name);
free(rrset);
}