mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 03:50:00 -04:00
[v9_9] silence coverity warnings
3401. [bug] Addressed Coverity warnings. [RT #31484]
(cherry picked from commit 47c5b8af92)
This commit is contained in:
parent
b5f3efc5ff
commit
2589af5868
35 changed files with 250 additions and 104 deletions
2
CHANGES
2
CHANGES
|
|
@ -1,3 +1,5 @@
|
|||
3401. [bug] Addressed Coverity warnings. [RT #31484]
|
||||
|
||||
3400. [cleanup] "named -V" can now report a source ID string, defined
|
||||
in the "srcid" file in the build tree and normally set
|
||||
to the most recent git hash. [RT #31494]
|
||||
|
|
|
|||
|
|
@ -471,6 +471,7 @@ main(int argc, char **argv) {
|
|||
if (isc_commandline_option != '?')
|
||||
fprintf(stderr, "%s: invalid argument -%c\n",
|
||||
program, isc_commandline_option);
|
||||
/* FALLTHROUGH */
|
||||
case 'h':
|
||||
usage();
|
||||
|
||||
|
|
|
|||
|
|
@ -390,6 +390,7 @@ main(int argc, char **argv) {
|
|||
if (isc_commandline_option != '?')
|
||||
fprintf(stderr, "%s: invalid argument -%c\n",
|
||||
prog_name, isc_commandline_option);
|
||||
/* FALLTHROUGH */
|
||||
case 'h':
|
||||
usage();
|
||||
|
||||
|
|
|
|||
|
|
@ -1395,9 +1395,9 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
INSIST(client->recursionquota == NULL);
|
||||
|
||||
INSIST(client->state == TCP_CLIENT(client) ?
|
||||
INSIST(client->state == (TCP_CLIENT(client) ?
|
||||
NS_CLIENTSTATE_READING :
|
||||
NS_CLIENTSTATE_READY);
|
||||
NS_CLIENTSTATE_READY));
|
||||
|
||||
ns_client_requests++;
|
||||
|
||||
|
|
@ -2571,7 +2571,9 @@ get_client(ns_clientmgr_t *manager, ns_interface_t *ifp,
|
|||
ns_client_t *client;
|
||||
MTRACE("get client");
|
||||
|
||||
if (manager != NULL && manager->exiting)
|
||||
REQUIRE(manager != NULL);
|
||||
|
||||
if (manager->exiting)
|
||||
return (ISC_R_SHUTTINGDOWN);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -793,6 +793,7 @@ main(int argc, char **argv) {
|
|||
program, isc_commandline_option);
|
||||
usage(1);
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
case 'h':
|
||||
usage(0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -612,24 +612,26 @@ sig_fromfile(char *path, isc_buffer_t *iscbuf) {
|
|||
char *p;
|
||||
char *buf;
|
||||
|
||||
rval = stat(path, &sb);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
t_info("open failed, errno == %d\n", errno);
|
||||
return(1);
|
||||
}
|
||||
|
||||
rval = fstat(fd, &sb);
|
||||
if (rval != 0) {
|
||||
t_info("stat %s failed, errno == %d\n", path, errno);
|
||||
close(fd);
|
||||
return(1);
|
||||
}
|
||||
|
||||
buf = (char *) malloc((sb.st_size + 1) * sizeof(unsigned char));
|
||||
if (buf == NULL) {
|
||||
t_info("malloc failed, errno == %d\n", errno);
|
||||
close(fd);
|
||||
return(1);
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
t_info("open failed, errno == %d\n", errno);
|
||||
(void) free(buf);
|
||||
return(1);
|
||||
}
|
||||
|
||||
len = sb.st_size;
|
||||
p = buf;
|
||||
|
|
@ -703,10 +705,18 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname,
|
|||
/*
|
||||
* Read data from file in a form usable by dst_verify.
|
||||
*/
|
||||
rval = stat(datapath, &sb);
|
||||
fd = open(datapath, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
t_info("t2_sigchk: open failed %d\n", errno);
|
||||
++*nprobs;
|
||||
return;
|
||||
}
|
||||
|
||||
rval = fstat(fd, &sb);
|
||||
if (rval != 0) {
|
||||
t_info("t2_sigchk: stat (%s) failed %d\n", datapath, errno);
|
||||
++*nprobs;
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -714,14 +724,7 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname,
|
|||
if (data == NULL) {
|
||||
t_info("t2_sigchk: malloc failed %d\n", errno);
|
||||
++*nprobs;
|
||||
return;
|
||||
}
|
||||
|
||||
fd = open(datapath, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
t_info("t2_sigchk: open failed %d\n", errno);
|
||||
(void) free(data);
|
||||
++*nprobs;
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,13 +185,14 @@ chkdata(unsigned char *buf, size_t buflen, char *exp_data,
|
|||
* setup the buffer and return the data length.
|
||||
*/
|
||||
static int
|
||||
getmsg(char *datafile_name, unsigned char *buf, int buflen, isc_buffer_t *pbuf)
|
||||
getmsg(char *datafile_name, isc_buffer_t *pbuf)
|
||||
{
|
||||
int c;
|
||||
int len;
|
||||
int cnt;
|
||||
unsigned int len;
|
||||
unsigned int cnt;
|
||||
unsigned char *p;
|
||||
FILE *fp;
|
||||
unsigned int buflen;
|
||||
|
||||
fp = fopen(datafile_name, "r");
|
||||
if (fp == NULL) {
|
||||
|
|
@ -199,7 +200,8 @@ getmsg(char *datafile_name, unsigned char *buf, int buflen, isc_buffer_t *pbuf)
|
|||
return (0);
|
||||
}
|
||||
|
||||
p = buf;
|
||||
p = isc_buffer_used(pbuf);
|
||||
buflen = isc_buffer_availablelength(pbuf);
|
||||
cnt = 0;
|
||||
len = 0;
|
||||
while ((c = getc(fp)) != EOF) {
|
||||
|
|
@ -248,7 +250,6 @@ getmsg(char *datafile_name, unsigned char *buf, int buflen, isc_buffer_t *pbuf)
|
|||
}
|
||||
|
||||
*p = '\0';
|
||||
isc_buffer_init(pbuf, buf, cnt);
|
||||
isc_buffer_add(pbuf, cnt);
|
||||
return (cnt);
|
||||
}
|
||||
|
|
@ -2014,7 +2015,10 @@ test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase,
|
|||
dns_decompress_t dctx;
|
||||
|
||||
t_info("testing using %s\n", datafile_name);
|
||||
len = getmsg(datafile_name, buf1, BIGBUFLEN, &iscbuf1);
|
||||
isc_buffer_init(&iscbuf1, buf1, sizeof(buf1));
|
||||
len = getmsg(datafile_name, &iscbuf1);
|
||||
if (len == 0)
|
||||
return (T_FAIL);
|
||||
|
||||
isc_buffer_setactive(&iscbuf1, len);
|
||||
iscbuf1.current = testname_offset;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ add_name(struct dlz_example_data *state, struct record *list,
|
|||
}
|
||||
strcpy(list[i].name, name);
|
||||
strcpy(list[i].type, type);
|
||||
strcpy(list[i].data, data);
|
||||
strncpy(list[i].data, data, sizeof(list[i].data));
|
||||
list[i].ttl = ttl;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
@ -307,7 +307,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
isc_boolean_t found = ISC_FALSE;
|
||||
isc_sockaddr_t *src;
|
||||
char full_name[100];
|
||||
char full_name[256];
|
||||
int i;
|
||||
|
||||
UNUSED(zone);
|
||||
|
|
@ -315,10 +315,11 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||
if (state->putrr == NULL)
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
|
||||
if (strcmp(name, "@") == 0)
|
||||
strcpy(full_name, state->zone_name);
|
||||
else
|
||||
sprintf(full_name, "%s.%s", name, state->zone_name);
|
||||
if (strcmp(name, "@") == 0) {
|
||||
strncpy(full_name, state->zone_name, 255);
|
||||
full_name[255] = '\0';
|
||||
} else
|
||||
snprintf(full_name, 255, "%s.%s", name, state->zone_name);
|
||||
|
||||
if (strcmp(name, "source-addr") == 0) {
|
||||
char buf[100];
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ main(int argc, char **argv) {
|
|||
if (isc_commandline_option != '?')
|
||||
fprintf(stderr, "%s: invalid argument -%c\n",
|
||||
program, isc_commandline_option);
|
||||
/* FALLTHROUGH */
|
||||
case 'h':
|
||||
usage();
|
||||
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ create_path(const char *zone, const char *host, const char *client,
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
process_dir(isc_dir_t dir, void *passback, config_data_t *cd,
|
||||
process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
|
||||
dlist_t *dir_list, unsigned int basedirlen)
|
||||
{
|
||||
|
||||
|
|
@ -386,10 +386,10 @@ process_dir(isc_dir_t dir, void *passback, config_data_t *cd,
|
|||
foundHost = ISC_FALSE;
|
||||
|
||||
/* copy base directory name to tmp. */
|
||||
strcpy(tmp, dir.dirname);
|
||||
strcpy(tmp, dir->dirname);
|
||||
|
||||
/* dir.dirname will always have '*' as the last char. */
|
||||
astPos = strlen(dir.dirname) - 1;
|
||||
/* dir->dirname will always have '*' as the last char. */
|
||||
astPos = strlen(dir->dirname) - 1;
|
||||
|
||||
/* if dir_list != NULL, were are performing a zone xfr */
|
||||
if (dir_list != NULL) {
|
||||
|
|
@ -425,46 +425,48 @@ process_dir(isc_dir_t dir, void *passback, config_data_t *cd,
|
|||
|
||||
foundHost = ISC_TRUE;
|
||||
/* set tmp again for use later */
|
||||
strcpy(tmp, dir.dirname);
|
||||
strcpy(tmp, dir->dirname);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* if splitcnt != 0 determine host from
|
||||
* ".host" directory entry
|
||||
*/
|
||||
while (isc_dir_read(&dir) == ISC_R_SUCCESS) {
|
||||
while (isc_dir_read(dir) == ISC_R_SUCCESS) {
|
||||
if (strncasecmp(".host",
|
||||
dir.entry.name, 5) == 0) {
|
||||
dir->entry.name, 5) == 0) {
|
||||
/*
|
||||
* handle filesystem's special
|
||||
* wildcard "-"
|
||||
*/
|
||||
if (strcmp((char *) &dir.entry.name[6],
|
||||
if (strcmp((char *) &dir->entry.name[6],
|
||||
"-") == 0)
|
||||
strcpy(host, "*");
|
||||
else
|
||||
strcpy(host,
|
||||
(char *)
|
||||
&dir.entry.name[6]);
|
||||
else {
|
||||
strncpy(host,
|
||||
(char *) &dir->entry.name[6],
|
||||
sizeof(host) - 1);
|
||||
host[255] = '\0';
|
||||
}
|
||||
foundHost = ISC_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* reset dir list for use later */
|
||||
isc_dir_reset(&dir);
|
||||
isc_dir_reset(dir);
|
||||
} /* end of else */
|
||||
}
|
||||
|
||||
while (isc_dir_read(&dir) == ISC_R_SUCCESS) {
|
||||
while (isc_dir_read(dir) == ISC_R_SUCCESS) {
|
||||
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
|
||||
"Filesystem driver Dir name:"
|
||||
" '%s' Dir entry: '%s'\n",
|
||||
dir.dirname, dir.entry.name);
|
||||
dir->dirname, dir->entry.name);
|
||||
|
||||
/* skip any entries starting with "." */
|
||||
if (dir.entry.name[0] == '.')
|
||||
if (dir->entry.name[0] == '.')
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
|
@ -477,7 +479,7 @@ process_dir(isc_dir_t dir, void *passback, config_data_t *cd,
|
|||
tmp[astPos] = '\0';
|
||||
|
||||
/* add name to base directory name. */
|
||||
strcat(tmp, dir.entry.name);
|
||||
strcat(tmp, dir->entry.name);
|
||||
|
||||
/* make sure we can stat entry */
|
||||
if (stat(tmp, &sb) == 0 ) {
|
||||
|
|
@ -515,7 +517,7 @@ process_dir(isc_dir_t dir, void *passback, config_data_t *cd,
|
|||
} else /* if we cannot stat entry, skip it. */
|
||||
continue;
|
||||
|
||||
type = dir.entry.name;
|
||||
type = dir->entry.name;
|
||||
ttlStr = strchr(type, cd->separator);
|
||||
if (ttlStr == NULL) {
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||
|
|
@ -687,7 +689,7 @@ fs_allnodes(const char *zone, void *driverarg, void *dbdata,
|
|||
}
|
||||
|
||||
/* process the directory */
|
||||
result = process_dir(dir, allnodes, cd, dir_list, basepathlen);
|
||||
result = process_dir(&dir, allnodes, cd, dir_list, basepathlen);
|
||||
|
||||
/* close the directory */
|
||||
isc_dir_close(&dir);
|
||||
|
|
@ -712,7 +714,7 @@ fs_allnodes(const char *zone, void *driverarg, void *dbdata,
|
|||
}
|
||||
|
||||
/* process the directory */
|
||||
result = process_dir(dir, allnodes, cd, dir_list, basepathlen);
|
||||
result = process_dir(&dir, allnodes, cd, dir_list, basepathlen);
|
||||
|
||||
/* close the directory */
|
||||
isc_dir_close(&dir);
|
||||
|
|
@ -844,7 +846,7 @@ fs_lookup(const char *zone, const char *name, void *driverarg,
|
|||
}
|
||||
|
||||
/* process any records in the directory */
|
||||
result = process_dir(dir, lookup, (config_data_t *) dbdata, NULL, 0);
|
||||
result = process_dir(&dir, lookup, (config_data_t *) dbdata, NULL, 0);
|
||||
|
||||
/* close the directory */
|
||||
isc_dir_close(&dir);
|
||||
|
|
|
|||
|
|
@ -2075,6 +2075,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname,
|
|||
while (namehook != NULL) {
|
||||
entry = namehook->entry;
|
||||
bucket = entry->lock_bucket;
|
||||
INSIST(bucket != DNS_ADB_INVALIDBUCKET);
|
||||
LOCK(&adb->entrylocks[bucket]);
|
||||
|
||||
if (!FIND_RETURNLAME(find)
|
||||
|
|
@ -2105,6 +2106,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname,
|
|||
while (namehook != NULL) {
|
||||
entry = namehook->entry;
|
||||
bucket = entry->lock_bucket;
|
||||
INSIST(bucket != DNS_ADB_INVALIDBUCKET);
|
||||
LOCK(&adb->entrylocks[bucket]);
|
||||
|
||||
if (!FIND_RETURNLAME(find)
|
||||
|
|
|
|||
|
|
@ -2843,8 +2843,6 @@ get_udpsocket(dns_dispatchmgr_t *mgr, dns_dispatch_t *disp,
|
|||
result = open_socket(sockmgr, localaddr, 0, &sock, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto end;
|
||||
else if (!anyport)
|
||||
break;
|
||||
else if (portavailable(mgr, sock, NULL))
|
||||
break;
|
||||
if (held[i] != NULL)
|
||||
|
|
|
|||
|
|
@ -517,8 +517,7 @@ dst_key_fromnamedfile(const char *filename, const char *dirname,
|
|||
result = dst_key_read_public(newfilename, type, mctx, &pubkey);
|
||||
isc_mem_put(mctx, newfilename, newfilenamelen);
|
||||
newfilename = NULL;
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
RETERR(result);
|
||||
|
||||
if ((type & (DST_TYPE_PRIVATE | DST_TYPE_PUBLIC)) == DST_TYPE_PUBLIC ||
|
||||
(pubkey->key_flags & DNS_KEYFLAG_TYPEMASK) == DNS_KEYTYPE_NOKEY) {
|
||||
|
|
@ -582,7 +581,8 @@ dst_key_fromnamedfile(const char *filename, const char *dirname,
|
|||
isc_mem_put(mctx, newfilename, newfilenamelen);
|
||||
if (lex != NULL)
|
||||
isc_lex_destroy(&lex);
|
||||
dst_key_free(&key);
|
||||
if (key != NULL)
|
||||
dst_key_free(&key);
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1429,6 +1429,7 @@ dns_name_totext2(dns_name_t *name, unsigned int options, isc_buffer_t *target)
|
|||
case 0x24: /* '$' */
|
||||
if ((options & DNS_NAME_MASTERFILE) == 0)
|
||||
goto no_escape;
|
||||
/* FALLTHROUGH */
|
||||
case 0x22: /* '"' */
|
||||
case 0x28: /* '(' */
|
||||
case 0x29: /* ')' */
|
||||
|
|
|
|||
|
|
@ -4238,6 +4238,8 @@ dns_validator_send(dns_validator_t *validator) {
|
|||
|
||||
void
|
||||
dns_validator_cancel(dns_validator_t *validator) {
|
||||
dns_fetch_t *fetch = NULL;
|
||||
|
||||
REQUIRE(VALID_VALIDATOR(validator));
|
||||
|
||||
LOCK(&validator->lock);
|
||||
|
|
@ -4247,8 +4249,8 @@ dns_validator_cancel(dns_validator_t *validator) {
|
|||
if ((validator->attributes & VALATTR_CANCELED) == 0) {
|
||||
validator->attributes |= VALATTR_CANCELED;
|
||||
if (validator->event != NULL) {
|
||||
if (validator->fetch != NULL)
|
||||
dns_resolver_cancelfetch(validator->fetch);
|
||||
fetch = validator->fetch;
|
||||
validator->fetch = NULL;
|
||||
|
||||
if (validator->subvalidator != NULL)
|
||||
dns_validator_cancel(validator->subvalidator);
|
||||
|
|
@ -4259,6 +4261,10 @@ dns_validator_cancel(dns_validator_t *validator) {
|
|||
}
|
||||
}
|
||||
UNLOCK(&validator->lock);
|
||||
|
||||
/* Need to cancel fetch outside validator lock */
|
||||
if (fetch != NULL)
|
||||
dns_resolver_cancelfetch(fetch);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -485,6 +485,8 @@ view_flushanddetach(dns_view_t **viewp, isc_boolean_t flush) {
|
|||
view->flush = ISC_TRUE;
|
||||
isc_refcount_decrement(&view->references, &refs);
|
||||
if (refs == 0) {
|
||||
dns_zone_t *mkzone = NULL, *rdzone = NULL;
|
||||
|
||||
LOCK(&view->lock);
|
||||
if (!RESSHUTDOWN(view))
|
||||
dns_resolver_shutdown(view->resolver);
|
||||
|
|
@ -500,18 +502,29 @@ view_flushanddetach(dns_view_t **viewp, isc_boolean_t flush) {
|
|||
else
|
||||
dns_zt_detach(&view->zonetable);
|
||||
if (view->managed_keys != NULL) {
|
||||
mkzone = view->managed_keys;
|
||||
view->managed_keys = NULL;
|
||||
if (view->flush)
|
||||
dns_zone_flush(view->managed_keys);
|
||||
dns_zone_detach(&view->managed_keys);
|
||||
dns_zone_flush(mkzone);
|
||||
}
|
||||
if (view->redirect != NULL) {
|
||||
rdzone = view->redirect;
|
||||
view->redirect = NULL;
|
||||
if (view->flush)
|
||||
dns_zone_flush(view->redirect);
|
||||
dns_zone_detach(&view->redirect);
|
||||
dns_zone_flush(rdzone);
|
||||
}
|
||||
#endif
|
||||
done = all_done(view);
|
||||
UNLOCK(&view->lock);
|
||||
|
||||
#ifdef BIND9
|
||||
/* Need to detach zones outside view lock */
|
||||
if (mkzone != NULL)
|
||||
dns_zone_detach(&mkzone);
|
||||
|
||||
if (rdzone != NULL)
|
||||
dns_zone_detach(&rdzone);
|
||||
#endif
|
||||
}
|
||||
|
||||
*viewp = NULL;
|
||||
|
|
|
|||
|
|
@ -591,6 +591,7 @@ xfr_rr(dns_xfrin_ctx_t *xfr, dns_name_t *name, isc_uint32_t ttl,
|
|||
case XFRST_AXFR_END:
|
||||
case XFRST_IXFR_END:
|
||||
FAIL(DNS_R_EXTRADATA);
|
||||
break;
|
||||
default:
|
||||
INSIST(0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1043,7 +1043,8 @@ zone_free(dns_zone_t *zone) {
|
|||
}
|
||||
|
||||
/*
|
||||
* Returns ISC_TRUE iff this the signed side of an inline-signing zone
|
||||
* Returns ISC_TRUE iff this the signed side of an inline-signing zone.
|
||||
* Caller should hold zone lock.
|
||||
*/
|
||||
static inline isc_boolean_t
|
||||
inline_secure(dns_zone_t *zone) {
|
||||
|
|
@ -1055,6 +1056,7 @@ inline_secure(dns_zone_t *zone) {
|
|||
|
||||
/*
|
||||
* Returns ISC_TRUE iff this the unsigned side of an inline-signing zone
|
||||
* Caller should hold zone lock.
|
||||
*/
|
||||
static inline isc_boolean_t
|
||||
inline_raw(dns_zone_t *zone) {
|
||||
|
|
@ -1489,11 +1491,15 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
|
|||
isc_time_t now;
|
||||
isc_time_t loadtime, filetime;
|
||||
dns_db_t *db = NULL;
|
||||
isc_boolean_t rbt;
|
||||
isc_boolean_t rbt, hasraw;
|
||||
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
|
||||
if (inline_secure(zone)) {
|
||||
LOCK_ZONE(zone);
|
||||
hasraw = inline_secure(zone);
|
||||
UNLOCK_ZONE(zone);
|
||||
|
||||
if (hasraw) {
|
||||
result = zone_load(zone->raw, flags);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return(result);
|
||||
|
|
@ -1502,7 +1508,7 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
|
|||
/*
|
||||
* Lock hierachy zmgr, raw, zone.
|
||||
*/
|
||||
if (inline_secure(zone))
|
||||
if (hasraw)
|
||||
LOCK_ZONE(zone->raw);
|
||||
LOCK_ZONE(zone);
|
||||
TIME_NOW(&now);
|
||||
|
|
@ -1659,7 +1665,7 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
|
|||
|
||||
cleanup:
|
||||
UNLOCK_ZONE(zone);
|
||||
if (inline_secure(zone))
|
||||
if (hasraw)
|
||||
UNLOCK_ZONE(zone->raw);
|
||||
if (db != NULL)
|
||||
dns_db_detach(&db);
|
||||
|
|
@ -8622,7 +8628,7 @@ zone_maintenance(dns_zone_t *zone) {
|
|||
void
|
||||
dns_zone_markdirty(dns_zone_t *zone) {
|
||||
isc_uint32_t serial;
|
||||
isc_result_t result;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
LOCK_ZONE(zone);
|
||||
if (zone->type == dns_zone_master) {
|
||||
|
|
@ -8639,7 +8645,10 @@ dns_zone_markdirty(dns_zone_t *zone) {
|
|||
if (result == ISC_R_SUCCESS)
|
||||
zone_send_secureserial(zone, ISC_FALSE, serial);
|
||||
}
|
||||
set_resigntime(zone); /* XXXMPA make separate call back */
|
||||
|
||||
/* XXXMPA make separate call back */
|
||||
if (result == ISC_R_SUCCESS)
|
||||
set_resigntime(zone);
|
||||
}
|
||||
zone_needdump(zone, DNS_DUMP_DELAY);
|
||||
UNLOCK_ZONE(zone);
|
||||
|
|
@ -13265,6 +13274,7 @@ zone_loaddone(void *arg, isc_result_t result) {
|
|||
dns_load_t *load = arg;
|
||||
dns_zone_t *zone;
|
||||
isc_result_t tresult;
|
||||
isc_boolean_t hasraw;
|
||||
|
||||
REQUIRE(DNS_LOAD_VALID(load));
|
||||
zone = load->zone;
|
||||
|
|
@ -13279,22 +13289,26 @@ zone_loaddone(void *arg, isc_result_t result) {
|
|||
/*
|
||||
* Lock hierachy zmgr, raw, zone.
|
||||
*/
|
||||
if (inline_secure(zone))
|
||||
LOCK_ZONE(zone);
|
||||
hasraw = inline_secure(zone);
|
||||
UNLOCK_ZONE(zone);
|
||||
|
||||
if (hasraw )
|
||||
LOCK_ZONE(zone->raw);
|
||||
LOCK_ZONE(load->zone);
|
||||
(void)zone_postload(load->zone, load->db, load->loadtime, result);
|
||||
zonemgr_putio(&load->zone->readio);
|
||||
DNS_ZONE_CLRFLAG(load->zone, DNS_ZONEFLG_LOADING);
|
||||
LOCK_ZONE(zone);
|
||||
(void)zone_postload(zone, load->db, load->loadtime, result);
|
||||
zonemgr_putio(&zone->readio);
|
||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADING);
|
||||
zone_idetach(&load->callbacks.zone);
|
||||
/*
|
||||
* Leave the zone frozen if the reload fails.
|
||||
*/
|
||||
if ((result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE) &&
|
||||
DNS_ZONE_FLAG(load->zone, DNS_ZONEFLG_THAW))
|
||||
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_THAW))
|
||||
zone->update_disabled = ISC_FALSE;
|
||||
DNS_ZONE_CLRFLAG(load->zone, DNS_ZONEFLG_THAW);
|
||||
UNLOCK_ZONE(load->zone);
|
||||
if (inline_secure(zone))
|
||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_THAW);
|
||||
UNLOCK_ZONE(zone);
|
||||
if (hasraw )
|
||||
UNLOCK_ZONE(zone->raw);
|
||||
|
||||
load->magic = 0;
|
||||
|
|
@ -15849,17 +15863,23 @@ dns_zone_dlzpostload(dns_zone_t *zone, dns_db_t *db)
|
|||
{
|
||||
isc_time_t loadtime;
|
||||
isc_result_t result;
|
||||
isc_boolean_t hasraw;
|
||||
|
||||
TIME_NOW(&loadtime);
|
||||
|
||||
/*
|
||||
* Lock hierachy zmgr, raw, zone.
|
||||
*/
|
||||
if (inline_secure(zone))
|
||||
LOCK_ZONE(zone);
|
||||
hasraw = inline_secure(zone);
|
||||
UNLOCK_ZONE(zone);
|
||||
|
||||
if (hasraw)
|
||||
LOCK_ZONE(zone->raw);
|
||||
LOCK_ZONE(zone);
|
||||
result = zone_postload(zone, db, loadtime, ISC_R_SUCCESS);
|
||||
UNLOCK_ZONE(zone);
|
||||
if (inline_secure(zone))
|
||||
if (hasraw)
|
||||
UNLOCK_ZONE(zone->raw);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,9 @@ make_querymessage(dns_message_t *message, const char *namestr,
|
|||
isc_buffer_t b;
|
||||
size_t namelen;
|
||||
|
||||
REQUIRE(message != NULL);
|
||||
REQUIRE(namestr != NULL);
|
||||
|
||||
/* Construct qname */
|
||||
namelen = strlen(namestr);
|
||||
isc_buffer_init(&b, namestr, namelen);
|
||||
|
|
@ -115,8 +118,7 @@ make_querymessage(dns_message_t *message, const char *namestr,
|
|||
dns_message_puttempname(message, &qname);
|
||||
if (qrdataset != NULL)
|
||||
dns_message_puttemprdataset(message, &qrdataset);
|
||||
if (message != NULL)
|
||||
dns_message_destroy(&message);
|
||||
dns_message_destroy(&message);
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1146,10 +1146,8 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
|
|||
UNUSED(flags);
|
||||
|
||||
ai = ai_clone(*aip, AF_INET6); /* don't use ai_clone() */
|
||||
if (ai == NULL) {
|
||||
freeaddrinfo(*aip);
|
||||
if (ai == NULL)
|
||||
return (EAI_MEMORY);
|
||||
}
|
||||
|
||||
*aip = ai;
|
||||
ai->ai_socktype = socktype;
|
||||
|
|
|
|||
|
|
@ -328,6 +328,7 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
|
|||
case DNS_R_NOVALIDDS:
|
||||
case DNS_R_NOVALIDSIG:
|
||||
ERR(EAI_INSECUREDATA);
|
||||
break;
|
||||
default:
|
||||
ERR(EAI_FAIL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ add_server(isc_mem_t *mctx, const char *address_str,
|
|||
goto cleanup;
|
||||
}
|
||||
address->length = res->ai_addrlen;
|
||||
memcpy(&address->type.sa, res->ai_addr, res->ai_addrlen);
|
||||
memcpy(&address->type.ss, res->ai_addr, res->ai_addrlen);
|
||||
ISC_LINK_INIT(address, link);
|
||||
ISC_LIST_APPEND(*nameservers, address, link);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@
|
|||
|
||||
#define ISC_QUEUE_INIT(queue, link) \
|
||||
do { \
|
||||
isc_mutex_init(&(queue).taillock); \
|
||||
isc_mutex_init(&(queue).headlock); \
|
||||
(void) isc_mutex_init(&(queue).taillock); \
|
||||
(void) isc_mutex_init(&(queue).headlock); \
|
||||
(queue).tail = (queue).head = NULL; \
|
||||
} while (0)
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ struct isc_sockaddr {
|
|||
struct sockaddr sa;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
struct sockaddr_storage ss;
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
struct sockaddr_un sunix;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ static char rcsid[] = "$Id: inet_aton.c,v 1.23 2008/12/01 23:47:45 tbox Exp $";
|
|||
*/
|
||||
int
|
||||
isc_net_aton(const char *cp, struct in_addr *addr) {
|
||||
unsigned long val;
|
||||
isc_uint32_t val;
|
||||
int base, n;
|
||||
unsigned char c;
|
||||
isc_uint8_t parts[4];
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ isc_ratelimiter_stall(isc_ratelimiter_t *rl) {
|
|||
result = isc_timer_reset(rl->timer, isc_timertype_inactive,
|
||||
NULL, NULL, ISC_FALSE);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
/* FALLTHROUGH */
|
||||
case isc_ratelimiter_idle:
|
||||
case isc_ratelimiter_stalled:
|
||||
rl->state = isc_ratelimiter_stalled;
|
||||
|
|
|
|||
|
|
@ -219,13 +219,12 @@ isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only) {
|
|||
break;
|
||||
case AF_INET6:
|
||||
in6 = &sockaddr->type.sin6.sin6_addr;
|
||||
s = (const unsigned char *)in6;
|
||||
if (IN6_IS_ADDR_V4MAPPED(in6)) {
|
||||
s = (const unsigned char *)&in6[12];
|
||||
s += 12;
|
||||
length = sizeof(sockaddr->type.sin.sin_addr.s_addr);
|
||||
} else {
|
||||
s = (const unsigned char *)in6;
|
||||
} else
|
||||
length = sizeof(sockaddr->type.sin6.sin6_addr);
|
||||
}
|
||||
p = ntohs(sockaddr->type.sin6.sin6_port);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -36,12 +36,13 @@ LIBS = @LIBS@ @ATFLIBS@
|
|||
|
||||
OBJS = isctest.@O@
|
||||
SRCS = isctest.c taskpool_test.c socket_test.c hash_test.c \
|
||||
symtab_test.c task_test.c queue_test.c parse_test.c
|
||||
sockaddr_test.c symtab_test.c task_test.c queue_test.c \
|
||||
parse_test.c
|
||||
|
||||
SUBDIRS =
|
||||
TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
||||
symtab_test@EXEEXT@ task_test@EXEEXT@ queue_test@EXEEXT@ \
|
||||
parse_test@EXEEXT@
|
||||
sockaddr_test@EXEEXT@ symtab_test@EXEEXT@ task_test@EXEEXT@ \
|
||||
queue_test@EXEEXT@ parse_test@EXEEXT@
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
|
|
@ -73,10 +74,14 @@ parse_test@EXEEXT@: parse_test.@O@ isctest.@O@ ${ISCDEPLIBS}
|
|||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
parse_test.@O@ isctest.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
sockaddr_test@EXEEXT@: sockaddr_test.@O@ isctest.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
sockaddr_test.@O@ isctest.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
|
||||
unit::
|
||||
sh ${top_srcdir}/unit/unittest.sh
|
||||
|
||||
clean distclean::
|
||||
rm -f ${TARGETS}
|
||||
rm -f atf.out
|
||||
rm -f atf.out
|
||||
|
|
|
|||
78
lib/isc/tests/sockaddr_test.c
Normal file
78
lib/isc/tests/sockaddr_test.c
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/sockaddr.h>
|
||||
#include <isc/print.h>
|
||||
|
||||
#include "isctest.h"
|
||||
|
||||
/*
|
||||
* Individual unit tests
|
||||
*/
|
||||
|
||||
ATF_TC(sockaddr_hash);
|
||||
ATF_TC_HEAD(sockaddr_hash, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "sockaddr hash");
|
||||
}
|
||||
ATF_TC_BODY(sockaddr_hash, tc) {
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t addr;
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
unsigned int h1, h2, h3, h4;
|
||||
int ret;
|
||||
|
||||
UNUSED(tc);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
in.s_addr = inet_addr("127.0.0.1");
|
||||
isc_sockaddr_fromin(&addr, &in, 1);
|
||||
h1 = isc_sockaddr_hash(&addr, ISC_TRUE);
|
||||
h2 = isc_sockaddr_hash(&addr, ISC_FALSE);
|
||||
ATF_CHECK(h1 != h2);
|
||||
|
||||
ret = inet_pton(AF_INET6, "::ffff:127.0.0.1", &in6);
|
||||
ATF_CHECK(ret == 1);
|
||||
isc_sockaddr_fromin6(&addr, &in6, 1);
|
||||
h3 = isc_sockaddr_hash(&addr, ISC_TRUE);
|
||||
h4 = isc_sockaddr_hash(&addr, ISC_FALSE);
|
||||
ATF_CHECK(h1 == h3);
|
||||
ATF_CHECK(h2 == h4);
|
||||
|
||||
isc_test_end();
|
||||
}
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
ATF_TP_ADD_TCS(tp) {
|
||||
ATF_TP_ADD_TC(tp, sockaddr_hash);
|
||||
|
||||
return (atf_no_error());
|
||||
}
|
||||
|
||||
|
|
@ -692,7 +692,7 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) {
|
|||
|
||||
while (manager->nscheduled > 0 && !done) {
|
||||
timer = isc_heap_element(manager->heap, 1);
|
||||
INSIST(timer->type != isc_timertype_inactive);
|
||||
INSIST(timer != NULL && timer->type != isc_timertype_inactive);
|
||||
if (isc_time_compare(now, &timer->due) >= 0) {
|
||||
if (timer->type == isc_timertype_ticker) {
|
||||
type = ISC_TIMEREVENT_TICK;
|
||||
|
|
|
|||
|
|
@ -301,8 +301,6 @@ try_ipv6only(void) {
|
|||
goto close;
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
||||
ipv6only_result = ISC_R_SUCCESS;
|
||||
|
||||
close:
|
||||
|
|
@ -358,7 +356,6 @@ try_ipv6pktinfo(void) {
|
|||
goto close;
|
||||
}
|
||||
|
||||
close(s);
|
||||
ipv6pktinfo_result = ISC_R_SUCCESS;
|
||||
|
||||
close:
|
||||
|
|
|
|||
|
|
@ -377,6 +377,7 @@ lwres_context_send(lwres_context_t *ctx,
|
|||
lwresult = context_connect(ctx);
|
||||
if (lwresult != LWRES_R_SUCCESS)
|
||||
return (lwresult);
|
||||
INSIST(ctx->sock >= 0);
|
||||
}
|
||||
|
||||
ret = sendto(ctx->sock, sendbase, sendlen, 0, NULL, 0);
|
||||
|
|
|
|||
|
|
@ -955,7 +955,7 @@ copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num)
|
|||
npp = he->h_aliases;
|
||||
cpp = (he1 != NULL) ? he1->h_aliases
|
||||
: ((he2 != NULL) ? he2->h_aliases : NULL);
|
||||
while (*cpp != NULL) {
|
||||
while (cpp != NULL && *cpp != NULL) {
|
||||
len = strlen (*cpp) + 1;
|
||||
*npp = malloc(len);
|
||||
if (*npp == NULL)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ static char rcsid[] = "$Id: lwinetaton.c,v 1.16 2007/06/19 23:47:22 tbox Exp $";
|
|||
*/
|
||||
int
|
||||
lwres_net_aton(const char *cp, struct in_addr *addr) {
|
||||
unsigned long val;
|
||||
lwres_uint32_t val;
|
||||
int base, n;
|
||||
unsigned char c;
|
||||
lwres_uint8_t parts[4];
|
||||
|
|
|
|||
|
|
@ -470,12 +470,16 @@ lwres__print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
|
|||
pad--;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D': /*deprecated*/
|
||||
INSIST("use %ld instead of %D" == NULL);
|
||||
break;
|
||||
case 'O': /*deprecated*/
|
||||
INSIST("use %lo instead of %O" == NULL);
|
||||
break;
|
||||
case 'U': /*deprecated*/
|
||||
INSIST("use %lu instead of %U" == NULL);
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
|
|
|
|||
Loading…
Reference in a new issue