mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 10:10:06 +00:00
more str{n}{cat,cpy} corrections rt45981_stage2
This commit is contained in:
parent
bbe9f1dd95
commit
cb629cdeda
@ -978,8 +978,7 @@ plus_option(char *option) {
|
|||||||
char *cmd, *value, *ptr;
|
char *cmd, *value, *ptr;
|
||||||
isc_boolean_t state = ISC_TRUE;
|
isc_boolean_t state = ISC_TRUE;
|
||||||
|
|
||||||
strncpy(option_store, option, sizeof(option_store));
|
strlcpy(option_store, option, sizeof(option_store));
|
||||||
option_store[sizeof(option_store)-1]=0;
|
|
||||||
ptr = option_store;
|
ptr = option_store;
|
||||||
cmd = next_token(&ptr,"=");
|
cmd = next_token(&ptr,"=");
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
|
@ -669,33 +669,27 @@ cleanup:
|
|||||||
static void
|
static void
|
||||||
printgreeting(int argc, char **argv, dig_lookup_t *lookup) {
|
printgreeting(int argc, char **argv, dig_lookup_t *lookup) {
|
||||||
int i;
|
int i;
|
||||||
size_t remaining;
|
|
||||||
static isc_boolean_t first = ISC_TRUE;
|
static isc_boolean_t first = ISC_TRUE;
|
||||||
char append[MXNAME];
|
char append[MXNAME];
|
||||||
|
|
||||||
if (printcmd) {
|
if (printcmd) {
|
||||||
lookup->cmdline[sizeof(lookup->cmdline) - 1] = 0;
|
|
||||||
snprintf(lookup->cmdline, sizeof(lookup->cmdline),
|
snprintf(lookup->cmdline, sizeof(lookup->cmdline),
|
||||||
"%s; <<>> DiG " VERSION " <<>>",
|
"%s; <<>> DiG " VERSION " <<>>",
|
||||||
first?"\n":"");
|
first?"\n":"");
|
||||||
i = 1;
|
i = 1;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
snprintf(append, sizeof(append), " %s", argv[i++]);
|
snprintf(append, sizeof(append), " %s", argv[i++]);
|
||||||
remaining = sizeof(lookup->cmdline) -
|
strlcat(lookup->cmdline, append,
|
||||||
strlen(lookup->cmdline) - 1;
|
sizeof(lookup->cmdline));
|
||||||
strncat(lookup->cmdline, append, remaining);
|
|
||||||
}
|
}
|
||||||
remaining = sizeof(lookup->cmdline) -
|
strlcat(lookup->cmdline, "\n", sizeof(lookup->cmdline));
|
||||||
strlen(lookup->cmdline) - 1;
|
|
||||||
strncat(lookup->cmdline, "\n", remaining);
|
|
||||||
if (first && addresscount != 0) {
|
if (first && addresscount != 0) {
|
||||||
snprintf(append, sizeof(append),
|
snprintf(append, sizeof(append),
|
||||||
"; (%d server%s found)\n",
|
"; (%d server%s found)\n",
|
||||||
addresscount,
|
addresscount,
|
||||||
addresscount > 1 ? "s" : "");
|
addresscount > 1 ? "s" : "");
|
||||||
remaining = sizeof(lookup->cmdline) -
|
strlcat(lookup->cmdline, append,
|
||||||
strlen(lookup->cmdline) - 1;
|
sizeof(lookup->cmdline));
|
||||||
strncat(lookup->cmdline, append, remaining);
|
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
snprintf(append, sizeof(append),
|
snprintf(append, sizeof(append),
|
||||||
@ -703,9 +697,8 @@ printgreeting(int argc, char **argv, dig_lookup_t *lookup) {
|
|||||||
short_form ? " +short" : "",
|
short_form ? " +short" : "",
|
||||||
printcmd ? " +cmd" : "");
|
printcmd ? " +cmd" : "");
|
||||||
first = ISC_FALSE;
|
first = ISC_FALSE;
|
||||||
remaining = sizeof(lookup->cmdline) -
|
strlcat(lookup->cmdline, append,
|
||||||
strlen(lookup->cmdline) - 1;
|
sizeof(lookup->cmdline));
|
||||||
strncat(lookup->cmdline, append, remaining);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -728,8 +721,7 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
isc_boolean_t state = ISC_TRUE;
|
isc_boolean_t state = ISC_TRUE;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
strncpy(option_store, option, sizeof(option_store));
|
strlcpy(option_store, option, sizeof(option_store));
|
||||||
option_store[sizeof(option_store)-1]=0;
|
|
||||||
ptr = option_store;
|
ptr = option_store;
|
||||||
cmd = next_token(&ptr, "=");
|
cmd = next_token(&ptr, "=");
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
@ -905,8 +897,7 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
|
|||||||
goto need_value;
|
goto need_value;
|
||||||
if (!state)
|
if (!state)
|
||||||
goto invalid_option;
|
goto invalid_option;
|
||||||
strncpy(domainopt, value, sizeof(domainopt));
|
strlcpy(domainopt, value, sizeof(domainopt));
|
||||||
domainopt[sizeof(domainopt)-1] = '\0';
|
|
||||||
break;
|
break;
|
||||||
case 's': /* dscp */
|
case 's': /* dscp */
|
||||||
FULLCHECK("dscp");
|
FULLCHECK("dscp");
|
||||||
@ -1598,8 +1589,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
|
|||||||
batchname = value;
|
batchname = value;
|
||||||
return (value_from_next);
|
return (value_from_next);
|
||||||
case 'k':
|
case 'k':
|
||||||
strncpy(keyfile, value, sizeof(keyfile));
|
strlcpy(keyfile, value, sizeof(keyfile));
|
||||||
keyfile[sizeof(keyfile)-1]=0;
|
|
||||||
return (value_from_next);
|
return (value_from_next);
|
||||||
case 'p':
|
case 'p':
|
||||||
result = parse_uint(&num, value, MAXPORT, "port number");
|
result = parse_uint(&num, value, MAXPORT, "port number");
|
||||||
@ -1613,9 +1603,8 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
|
|||||||
(*lookup) = clone_lookup(default_lookup,
|
(*lookup) = clone_lookup(default_lookup,
|
||||||
ISC_TRUE);
|
ISC_TRUE);
|
||||||
*need_clone = ISC_TRUE;
|
*need_clone = ISC_TRUE;
|
||||||
strncpy((*lookup)->textname, value,
|
strlcpy((*lookup)->textname, value,
|
||||||
sizeof((*lookup)->textname));
|
sizeof((*lookup)->textname));
|
||||||
(*lookup)->textname[sizeof((*lookup)->textname)-1]=0;
|
|
||||||
(*lookup)->trace_root = ISC_TF((*lookup)->trace ||
|
(*lookup)->trace_root = ISC_TF((*lookup)->trace ||
|
||||||
(*lookup)->ns_search_only);
|
(*lookup)->ns_search_only);
|
||||||
(*lookup)->new_search = ISC_TRUE;
|
(*lookup)->new_search = ISC_TRUE;
|
||||||
@ -1699,10 +1688,8 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
|
|||||||
#endif
|
#endif
|
||||||
digestbits = 0;
|
digestbits = 0;
|
||||||
}
|
}
|
||||||
strncpy(keynametext, ptr, sizeof(keynametext));
|
strlcpy(keynametext, ptr, sizeof(keynametext));
|
||||||
keynametext[sizeof(keynametext)-1]=0;
|
strlcpy(keysecret, ptr2, sizeof(keysecret));
|
||||||
strncpy(keysecret, ptr2, sizeof(keysecret));
|
|
||||||
keysecret[sizeof(keysecret)-1]=0;
|
|
||||||
return (value_from_next);
|
return (value_from_next);
|
||||||
case 'x':
|
case 'x':
|
||||||
if (*need_clone)
|
if (*need_clone)
|
||||||
@ -1710,9 +1697,8 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
|
|||||||
*need_clone = ISC_TRUE;
|
*need_clone = ISC_TRUE;
|
||||||
if (get_reverse(textname, sizeof(textname), value,
|
if (get_reverse(textname, sizeof(textname), value,
|
||||||
ip6_int, ISC_FALSE) == ISC_R_SUCCESS) {
|
ip6_int, ISC_FALSE) == ISC_R_SUCCESS) {
|
||||||
strncpy((*lookup)->textname, textname,
|
strlcpy((*lookup)->textname, textname,
|
||||||
sizeof((*lookup)->textname));
|
sizeof((*lookup)->textname));
|
||||||
(*lookup)->textname[sizeof((*lookup)->textname)-1] = 0;
|
|
||||||
debug("looking up %s", (*lookup)->textname);
|
debug("looking up %s", (*lookup)->textname);
|
||||||
(*lookup)->trace_root = ISC_TF((*lookup)->trace ||
|
(*lookup)->trace_root = ISC_TF((*lookup)->trace ||
|
||||||
(*lookup)->ns_search_only);
|
(*lookup)->ns_search_only);
|
||||||
@ -2006,9 +1992,8 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
|
|||||||
lookup = clone_lookup(default_lookup,
|
lookup = clone_lookup(default_lookup,
|
||||||
ISC_TRUE);
|
ISC_TRUE);
|
||||||
need_clone = ISC_TRUE;
|
need_clone = ISC_TRUE;
|
||||||
strncpy(lookup->textname, rv[0],
|
strlcpy(lookup->textname, rv[0],
|
||||||
sizeof(lookup->textname));
|
sizeof(lookup->textname));
|
||||||
lookup->textname[sizeof(lookup->textname)-1]=0;
|
|
||||||
lookup->trace_root = ISC_TF(lookup->trace ||
|
lookup->trace_root = ISC_TF(lookup->trace ||
|
||||||
lookup->ns_search_only);
|
lookup->ns_search_only);
|
||||||
lookup->new_search = ISC_TRUE;
|
lookup->new_search = ISC_TRUE;
|
||||||
|
@ -463,9 +463,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
|||||||
dns_name_format(name, namestr, sizeof(namestr));
|
dns_name_format(name, namestr, sizeof(namestr));
|
||||||
lookup = clone_lookup(query->lookup, ISC_FALSE);
|
lookup = clone_lookup(query->lookup, ISC_FALSE);
|
||||||
if (lookup != NULL) {
|
if (lookup != NULL) {
|
||||||
strncpy(lookup->textname, namestr,
|
strlcpy(lookup->textname, namestr,
|
||||||
sizeof(lookup->textname));
|
sizeof(lookup->textname));
|
||||||
lookup->textname[sizeof(lookup->textname)-1] = 0;
|
|
||||||
lookup->rdtype = dns_rdatatype_aaaa;
|
lookup->rdtype = dns_rdatatype_aaaa;
|
||||||
lookup->rdtypeset = ISC_TRUE;
|
lookup->rdtypeset = ISC_TRUE;
|
||||||
lookup->origin = NULL;
|
lookup->origin = NULL;
|
||||||
@ -474,9 +473,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
|||||||
}
|
}
|
||||||
lookup = clone_lookup(query->lookup, ISC_FALSE);
|
lookup = clone_lookup(query->lookup, ISC_FALSE);
|
||||||
if (lookup != NULL) {
|
if (lookup != NULL) {
|
||||||
strncpy(lookup->textname, namestr,
|
strlcpy(lookup->textname, namestr,
|
||||||
sizeof(lookup->textname));
|
sizeof(lookup->textname));
|
||||||
lookup->textname[sizeof(lookup->textname)-1] = 0;
|
|
||||||
lookup->rdtype = dns_rdatatype_mx;
|
lookup->rdtype = dns_rdatatype_mx;
|
||||||
lookup->rdtypeset = ISC_TRUE;
|
lookup->rdtypeset = ISC_TRUE;
|
||||||
lookup->origin = NULL;
|
lookup->origin = NULL;
|
||||||
@ -861,14 +859,12 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
|
|||||||
lookup->pending = ISC_FALSE;
|
lookup->pending = ISC_FALSE;
|
||||||
if (get_reverse(store, sizeof(store), hostname,
|
if (get_reverse(store, sizeof(store), hostname,
|
||||||
lookup->ip6_int, ISC_TRUE) == ISC_R_SUCCESS) {
|
lookup->ip6_int, ISC_TRUE) == ISC_R_SUCCESS) {
|
||||||
strncpy(lookup->textname, store, sizeof(lookup->textname));
|
strlcpy(lookup->textname, store, sizeof(lookup->textname));
|
||||||
lookup->textname[sizeof(lookup->textname)-1] = 0;
|
|
||||||
lookup->rdtype = dns_rdatatype_ptr;
|
lookup->rdtype = dns_rdatatype_ptr;
|
||||||
lookup->rdtypeset = ISC_TRUE;
|
lookup->rdtypeset = ISC_TRUE;
|
||||||
default_lookups = ISC_FALSE;
|
default_lookups = ISC_FALSE;
|
||||||
} else {
|
} else {
|
||||||
strncpy(lookup->textname, hostname, sizeof(lookup->textname));
|
strlcpy(lookup->textname, hostname, sizeof(lookup->textname));
|
||||||
lookup->textname[sizeof(lookup->textname)-1]=0;
|
|
||||||
usesearch = ISC_TRUE;
|
usesearch = ISC_TRUE;
|
||||||
}
|
}
|
||||||
lookup->new_search = ISC_TRUE;
|
lookup->new_search = ISC_TRUE;
|
||||||
|
@ -479,9 +479,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
|||||||
dns_name_format(name, namestr, sizeof(namestr));
|
dns_name_format(name, namestr, sizeof(namestr));
|
||||||
lookup = clone_lookup(query->lookup, ISC_FALSE);
|
lookup = clone_lookup(query->lookup, ISC_FALSE);
|
||||||
if (lookup != NULL) {
|
if (lookup != NULL) {
|
||||||
strncpy(lookup->textname, namestr,
|
strlcpy(lookup->textname, namestr,
|
||||||
sizeof(lookup->textname));
|
sizeof(lookup->textname));
|
||||||
lookup->textname[sizeof(lookup->textname)-1] = 0;
|
|
||||||
lookup->rdtype = dns_rdatatype_aaaa;
|
lookup->rdtype = dns_rdatatype_aaaa;
|
||||||
lookup->rdtypeset = ISC_TRUE;
|
lookup->rdtypeset = ISC_TRUE;
|
||||||
lookup->origin = NULL;
|
lookup->origin = NULL;
|
||||||
|
@ -49,8 +49,8 @@ ntservice_init(void) {
|
|||||||
}
|
}
|
||||||
UpdateSCM(SERVICE_RUNNING);
|
UpdateSCM(SERVICE_RUNNING);
|
||||||
} else {
|
} else {
|
||||||
strcpy(ConsoleTitle, "BIND Version ");
|
strlcpy(ConsoleTitle, "BIND Version ", sizeof(ConsoleTitle));
|
||||||
strcat(ConsoleTitle, VERSION);
|
strlcat(ConsoleTitle, VERSION, sizeof(ConsoleTitle));
|
||||||
SetConsoleTitle(ConsoleTitle);
|
SetConsoleTitle(ConsoleTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,8 +453,8 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
|
|||||||
return (ISC_FALSE);
|
return (ISC_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(buf, hmacstr, len);
|
/* Copy len bytes and NUL terminate. */
|
||||||
buf[len] = 0;
|
strlcpy(buf, hmacstr, ISC_MIN(len + 1, sizeof(buf)));
|
||||||
|
|
||||||
#ifndef PK11_MD5_DISABLE
|
#ifndef PK11_MD5_DISABLE
|
||||||
if (strcasecmp(buf, "hmac-md5") == 0) {
|
if (strcasecmp(buf, "hmac-md5") == 0) {
|
||||||
|
@ -106,7 +106,7 @@ my_recv(isc_task_t *task, isc_event_t *event) {
|
|||||||
region.base = isc_mem_get(mctx, strlen(buf) + 1);
|
region.base = isc_mem_get(mctx, strlen(buf) + 1);
|
||||||
if (region.base != NULL) {
|
if (region.base != NULL) {
|
||||||
region.length = strlen(buf) + 1;
|
region.length = strlen(buf) + 1;
|
||||||
strcpy((char *)region.base, buf); /* strcpy is safe */
|
strlcpy((char *)region.base, buf, region.length);
|
||||||
} else
|
} else
|
||||||
region.length = 0;
|
region.length = 0;
|
||||||
isc_socket_send(sock, ®ion, task, my_send, event->ev_arg);
|
isc_socket_send(sock, ®ion, task, my_send, event->ev_arg);
|
||||||
@ -179,7 +179,7 @@ my_connect(isc_task_t *task, isc_event_t *event) {
|
|||||||
region.base = isc_mem_get(mctx, strlen(buf) + 1);
|
region.base = isc_mem_get(mctx, strlen(buf) + 1);
|
||||||
if (region.base != NULL) {
|
if (region.base != NULL) {
|
||||||
region.length = strlen(buf) + 1;
|
region.length = strlen(buf) + 1;
|
||||||
strcpy((char *)region.base, buf); /* This strcpy is safe. */
|
strlcpy((char *)region.base, buf, region.length);
|
||||||
} else {
|
} else {
|
||||||
region.length = 0;
|
region.length = 0;
|
||||||
}
|
}
|
||||||
|
@ -1041,8 +1041,7 @@ plus_option(char *option, struct query *query, isc_boolean_t global)
|
|||||||
isc_boolean_t state = ISC_TRUE;
|
isc_boolean_t state = ISC_TRUE;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
strncpy(option_store, option, sizeof(option_store));
|
strlcpy(option_store, option, sizeof(option_store));
|
||||||
option_store[sizeof(option_store) - 1] = 0;
|
|
||||||
ptr = option_store;
|
ptr = option_store;
|
||||||
cmd = next_token(&ptr, "=");
|
cmd = next_token(&ptr, "=");
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
@ -1657,8 +1656,7 @@ dash_option(const char *option, char *next, struct query *query,
|
|||||||
return (value_from_next);
|
return (value_from_next);
|
||||||
case 'x':
|
case 'x':
|
||||||
get_reverse(textname, sizeof(textname), value, query->ip6_int);
|
get_reverse(textname, sizeof(textname), value, query->ip6_int);
|
||||||
strncpy(query->textname, textname, sizeof(query->textname));
|
strlcpy(query->textname, textname, sizeof(query->textname));
|
||||||
query->textname[sizeof(query->textname) - 1] = 0;
|
|
||||||
query->rdtype = dns_rdatatype_ptr;
|
query->rdtype = dns_rdatatype_ptr;
|
||||||
query->rdclass = dns_rdataclass_in;
|
query->rdclass = dns_rdataclass_in;
|
||||||
*setname = ISC_TRUE;
|
*setname = ISC_TRUE;
|
||||||
@ -1845,9 +1843,8 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (query == &default_query)
|
if (query == &default_query)
|
||||||
query = clone_default_query();
|
query = clone_default_query();
|
||||||
strncpy(query->textname, rv[0],
|
strlcpy(query->textname, rv[0],
|
||||||
sizeof(query->textname));
|
sizeof(query->textname));
|
||||||
query->textname[sizeof(query->textname) - 1] = 0;
|
|
||||||
ISC_LIST_APPEND(queries, query, link);
|
ISC_LIST_APPEND(queries, query, link);
|
||||||
|
|
||||||
query = clone_default_query();
|
query = clone_default_query();
|
||||||
|
@ -252,8 +252,8 @@ maybe_numeric(unsigned int *valuep, isc_textregion_t *source,
|
|||||||
* isc_parse_uint32(). isc_parse_uint32() requires
|
* isc_parse_uint32(). isc_parse_uint32() requires
|
||||||
* null termination, so we must make a copy.
|
* null termination, so we must make a copy.
|
||||||
*/
|
*/
|
||||||
strncpy(buffer, source->base, sizeof(buffer));
|
strlcpy(buffer, source->base,
|
||||||
buffer[sizeof(buffer) - 1] = '\0';
|
ISC_MIN(source->length + 1, sizeof(buffer)));
|
||||||
|
|
||||||
INSIST(buffer[source->length] == '\0');
|
INSIST(buffer[source->length] == '\0');
|
||||||
|
|
||||||
@ -504,8 +504,12 @@ dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
|
|||||||
char *endp;
|
char *endp;
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
|
|
||||||
strncpy(buf, source->base + 5, source->length - 5);
|
/*
|
||||||
buf[source->length - 5] = '\0';
|
* source->base is not required to be NUL terminated.
|
||||||
|
* Copy up to remaining bytes and NUL terminate.
|
||||||
|
*/
|
||||||
|
strlcpy(buf, source->base + 5,
|
||||||
|
ISC_MIN(source->length - 5 + 1, sizeof(buf)));
|
||||||
val = strtoul(buf, &endp, 10);
|
val = strtoul(buf, &endp, 10);
|
||||||
if (*endp == '\0' && val <= 0xffff) {
|
if (*endp == '\0' && val <= 0xffff) {
|
||||||
*classp = (dns_rdataclass_t)val;
|
*classp = (dns_rdataclass_t)val;
|
||||||
|
@ -1339,8 +1339,12 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
|
|||||||
char *endp;
|
char *endp;
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
|
|
||||||
strncpy(buf, source->base + 4, source->length - 4);
|
/*
|
||||||
buf[source->length - 4] = '\0';
|
* source->base is not required to be NUL terminated.
|
||||||
|
* Copy up to remaining bytes and NUL terminate.
|
||||||
|
*/
|
||||||
|
strlcpy(buf, source->base + 4,
|
||||||
|
ISC_MIN(source->length - 4 + 1, sizeof(buf)));
|
||||||
val = strtoul(buf, &endp, 10);
|
val = strtoul(buf, &endp, 10);
|
||||||
if (*endp == '\0' && val <= 0xffff) {
|
if (*endp == '\0' && val <= 0xffff) {
|
||||||
*typep = (dns_rdatatype_t)val;
|
*typep = (dns_rdatatype_t)val;
|
||||||
|
@ -159,8 +159,8 @@ bind_ttl(isc_textregion_t *source, isc_uint32_t *ttl) {
|
|||||||
*/
|
*/
|
||||||
if (source->length > sizeof(buf) - 1)
|
if (source->length > sizeof(buf) - 1)
|
||||||
return (DNS_R_SYNTAX);
|
return (DNS_R_SYNTAX);
|
||||||
strncpy(buf, source->base, source->length);
|
/* Copy source->length bytes and NUL terminate. */
|
||||||
buf[source->length] = '\0';
|
strlcpy(buf, source->base, ISC_MIN(source->length + 1, sizeof(buf)));
|
||||||
s = buf;
|
s = buf;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -1372,7 +1372,7 @@ dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx) {
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
isc_result_t result = ISC_R_SUCCESS;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
void *mem;
|
void *mem;
|
||||||
char **tmp, *tmp2;
|
char **tmp, *tmp2, *base;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
REQUIRE(argv != NULL && *argv == NULL);
|
REQUIRE(argv != NULL && *argv == NULL);
|
||||||
@ -1383,14 +1383,13 @@ dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx) {
|
|||||||
size += strlen(zone->db_argv[i]) + 1;
|
size += strlen(zone->db_argv[i]) + 1;
|
||||||
mem = isc_mem_allocate(mctx, size);
|
mem = isc_mem_allocate(mctx, size);
|
||||||
if (mem != NULL) {
|
if (mem != NULL) {
|
||||||
size_t remaining;
|
|
||||||
tmp = mem;
|
tmp = mem;
|
||||||
tmp2 = mem;
|
tmp2 = mem;
|
||||||
|
base = mem;
|
||||||
tmp2 += (zone->db_argc + 1) * sizeof(char *);
|
tmp2 += (zone->db_argc + 1) * sizeof(char *);
|
||||||
for (i = 0; i < zone->db_argc; i++) {
|
for (i = 0; i < zone->db_argc; i++) {
|
||||||
remaining = size - (tmp2 - (char *) mem);
|
|
||||||
*tmp++ = tmp2;
|
*tmp++ = tmp2;
|
||||||
strlcpy(tmp2, zone->db_argv[i], remaining);
|
strlcpy(tmp2, zone->db_argv[i], size - (tmp2 - base));
|
||||||
tmp2 += strlen(tmp2) + 1;
|
tmp2 += strlen(tmp2) + 1;
|
||||||
}
|
}
|
||||||
*tmp = NULL;
|
*tmp = NULL;
|
||||||
|
@ -374,8 +374,7 @@ getaddrinfo(const char *hostname, const char *servname,
|
|||||||
*/
|
*/
|
||||||
ntmp[0] = '\0';
|
ntmp[0] = '\0';
|
||||||
if (strchr(hostname, '%') != NULL) {
|
if (strchr(hostname, '%') != NULL) {
|
||||||
strncpy(ntmp, hostname, sizeof(ntmp) - 1);
|
strlcpy(ntmp, hostname, sizeof(ntmp));
|
||||||
ntmp[sizeof(ntmp) - 1] = '\0';
|
|
||||||
p = strchr(ntmp, '%');
|
p = strchr(ntmp, '%');
|
||||||
ep = NULL;
|
ep = NULL;
|
||||||
|
|
||||||
|
@ -1671,12 +1671,12 @@ isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
|
|||||||
REQUIRE(VALID_CONTEXT(mctx));
|
REQUIRE(VALID_CONTEXT(mctx));
|
||||||
REQUIRE(s != NULL);
|
REQUIRE(s != NULL);
|
||||||
|
|
||||||
len = strlen(s);
|
len = strlen(s) + 1;
|
||||||
|
|
||||||
ns = isc__mem_allocate((isc_mem_t *)mctx, len + 1 FLARG_PASS);
|
ns = isc__mem_allocate((isc_mem_t *)mctx, len FLARG_PASS);
|
||||||
|
|
||||||
if (ns != NULL)
|
if (ns != NULL)
|
||||||
strncpy(ns, s, len + 1);
|
strlcpy(ns, s, len);
|
||||||
|
|
||||||
return (ns);
|
return (ns);
|
||||||
}
|
}
|
||||||
@ -1827,8 +1827,7 @@ isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
|
|||||||
REQUIRE(VALID_CONTEXT(ctx));
|
REQUIRE(VALID_CONTEXT(ctx));
|
||||||
|
|
||||||
LOCK(&ctx->lock);
|
LOCK(&ctx->lock);
|
||||||
memset(ctx->name, 0, sizeof(ctx->name));
|
strlcpy(ctx->name, name, sizeof(ctx->name));
|
||||||
strncpy(ctx->name, name, sizeof(ctx->name) - 1);
|
|
||||||
ctx->tag = tag;
|
ctx->tag = tag;
|
||||||
UNLOCK(&ctx->lock);
|
UNLOCK(&ctx->lock);
|
||||||
}
|
}
|
||||||
@ -1913,8 +1912,7 @@ isc__mempool_setname(isc_mempool_t *mpctx0, const char *name) {
|
|||||||
if (mpctx->lock != NULL)
|
if (mpctx->lock != NULL)
|
||||||
LOCK(mpctx->lock);
|
LOCK(mpctx->lock);
|
||||||
|
|
||||||
strncpy(mpctx->name, name, sizeof(mpctx->name) - 1);
|
strlcpy(mpctx->name, name, sizeof(mpctx->name));
|
||||||
mpctx->name[sizeof(mpctx->name) - 1] = '\0';
|
|
||||||
|
|
||||||
if (mpctx->lock != NULL)
|
if (mpctx->lock != NULL)
|
||||||
UNLOCK(mpctx->lock);
|
UNLOCK(mpctx->lock);
|
||||||
|
@ -408,9 +408,13 @@ pk11_get_session(pk11_context_t *ctx, pk11_optype_t optype,
|
|||||||
/* Override the token's PIN */
|
/* Override the token's PIN */
|
||||||
if (logon && pin != NULL && *pin != '\0') {
|
if (logon && pin != NULL && *pin != '\0') {
|
||||||
if (strlen(pin) > PINLEN)
|
if (strlen(pin) > PINLEN)
|
||||||
return ISC_R_RANGE;
|
return (ISC_R_RANGE);
|
||||||
memset(token->pin, 0, PINLEN + 1);
|
/*
|
||||||
strncpy(token->pin, pin, PINLEN);
|
* We want to zero out the old pin before
|
||||||
|
* overwriting with a new one.
|
||||||
|
*/
|
||||||
|
memset(token->pin, 0, sizeof(token->pin));
|
||||||
|
strlcpy(token->pin, pin, sizeof(token->pin));
|
||||||
}
|
}
|
||||||
|
|
||||||
freelist = &token->sessions;
|
freelist = &token->sessions;
|
||||||
|
@ -882,8 +882,7 @@ isc__task_setname(isc_task_t *task0, const char *name, void *tag) {
|
|||||||
REQUIRE(VALID_TASK(task));
|
REQUIRE(VALID_TASK(task));
|
||||||
|
|
||||||
LOCK(&task->lock);
|
LOCK(&task->lock);
|
||||||
memset(task->name, 0, sizeof(task->name));
|
strlcpy(task->name, name, sizeof(task->name));
|
||||||
strncpy(task->name, name, sizeof(task->name) - 1);
|
|
||||||
task->tag = tag;
|
task->tag = tag;
|
||||||
UNLOCK(&task->lock);
|
UNLOCK(&task->lock);
|
||||||
}
|
}
|
||||||
|
@ -234,11 +234,12 @@ isc_file_template(const char *path, const char *templet, char *buf,
|
|||||||
s = strrchr(path, '/');
|
s = strrchr(path, '/');
|
||||||
|
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
if ((s - path + 1 + strlen(templet) + 1) > buflen)
|
size_t prefixlen = s - path + 1;
|
||||||
|
if ((prefixlen + strlen(templet) + 1) > buflen)
|
||||||
return (ISC_R_NOSPACE);
|
return (ISC_R_NOSPACE);
|
||||||
|
|
||||||
strncpy(buf, path, s - path + 1);
|
/* Copy 'prefixlen' bytes and NUL terminate. */
|
||||||
buf[s - path + 1] = '\0';
|
strlcpy(buf, path, ISC_MIN(prefixlen + 1, buflen));
|
||||||
strlcat(buf, templet, buflen);
|
strlcat(buf, templet, buflen);
|
||||||
} else {
|
} else {
|
||||||
if ((strlen(templet) + 1) > buflen)
|
if ((strlen(templet) + 1) > buflen)
|
||||||
|
@ -229,7 +229,7 @@ linux_if_inet6_current(isc_interfaceiter_t *iter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
isc_netaddr_fromin6(&iter->current.netmask, &addr6);
|
isc_netaddr_fromin6(&iter->current.netmask, &addr6);
|
||||||
strncpy(iter->current.name, name, sizeof(iter->current.name));
|
strlcpy(iter->current.name, name, sizeof(iter->current.name));
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -5634,7 +5634,7 @@ isc__socket_filter(isc_socket_t *sock0, const char *filter) {
|
|||||||
|
|
||||||
#if defined(SO_ACCEPTFILTER) && defined(ENABLE_ACCEPTFILTER)
|
#if defined(SO_ACCEPTFILTER) && defined(ENABLE_ACCEPTFILTER)
|
||||||
bzero(&afa, sizeof(afa));
|
bzero(&afa, sizeof(afa));
|
||||||
strncpy(afa.af_name, filter, sizeof(afa.af_name));
|
strlcpy(afa.af_name, filter, sizeof(afa.af_name));
|
||||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_ACCEPTFILTER,
|
if (setsockopt(sock->fd, SOL_SOCKET, SO_ACCEPTFILTER,
|
||||||
&afa, sizeof(afa)) == -1) {
|
&afa, sizeof(afa)) == -1) {
|
||||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||||
@ -6519,8 +6519,7 @@ isc__socket_setname(isc_socket_t *socket0, const char *name, void *tag) {
|
|||||||
REQUIRE(VALID_SOCKET(sock));
|
REQUIRE(VALID_SOCKET(sock));
|
||||||
|
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
memset(sock->name, 0, sizeof(sock->name));
|
strlcpy(sock->name, name, sizeof(sock->name));
|
||||||
strncpy(sock->name, name, sizeof(sock->name) - 1);
|
|
||||||
sock->tag = tag;
|
sock->tag = tag;
|
||||||
UNLOCK(&sock->lock);
|
UNLOCK(&sock->lock);
|
||||||
}
|
}
|
||||||
|
@ -394,8 +394,7 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
|
|||||||
snprintf(buf + flen, len - flen,
|
snprintf(buf + flen, len - flen,
|
||||||
".%03u", t->nanoseconds / NS_PER_MS);
|
".%03u", t->nanoseconds / NS_PER_MS);
|
||||||
else {
|
else {
|
||||||
strncpy(buf, "99-Bad-9999 99:99:99.999", len);
|
strlcpy(buf, "99-Bad-9999 99:99:99.999", len);
|
||||||
buf[len - 1] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,11 +334,12 @@ isc_file_template(const char *path, const char *templet, char *buf,
|
|||||||
s = strrchr(path, '\\');
|
s = strrchr(path, '\\');
|
||||||
|
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
if ((s - path + 1 + strlen(templet) + 1) > (ssize_t)buflen)
|
size_t prefixlen = s - path + 1;
|
||||||
|
if ((prefixlen + strlen(templet) + 1) > (ssize_t)buflen)
|
||||||
return (ISC_R_NOSPACE);
|
return (ISC_R_NOSPACE);
|
||||||
|
|
||||||
strncpy(buf, path, s - path + 1);
|
/* Copy 'prefixlen' bytes and NUL terminate. */
|
||||||
buf[s - path + 1] = '\0';
|
strlcpy(buf, path, ISC_MIN(prefixlen + 1, buflen));
|
||||||
strlcat(buf, templet, buflen);
|
strlcat(buf, templet, buflen);
|
||||||
} else {
|
} else {
|
||||||
if ((strlen(templet) + 1) > buflen)
|
if ((strlen(templet) + 1) > buflen)
|
||||||
@ -616,8 +617,8 @@ isc_file_progname(const char *filename, char *progname, size_t namelen) {
|
|||||||
if (len >= namelen)
|
if (len >= namelen)
|
||||||
return (ISC_R_NOSPACE);
|
return (ISC_R_NOSPACE);
|
||||||
|
|
||||||
strlcpy(progname, s, len);
|
/* Copy up to 'len' bytes and NUL terminate. */
|
||||||
progname[len] = '\0';
|
strlcpy(progname, s, ISC_MIN(len + 1, namelen));
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +70,9 @@ is_ntfs(const char * file) {
|
|||||||
*/
|
*/
|
||||||
if (isalpha(filename[0]) && filename[1] == ':' &&
|
if (isalpha(filename[0]) && filename[1] == ':' &&
|
||||||
(filename[2] == '\\' || filename[2] == '/')) {
|
(filename[2] == '\\' || filename[2] == '/')) {
|
||||||
strncpy(drive, filename, 3);
|
/* Copy 'c:\' or 'c:/' and NUL terminate. */
|
||||||
drive[3] = '\0';
|
strlcpy(drive, filename, ISC_MIN(3 + 1, sizeof(drive)));
|
||||||
}
|
} else if ((filename[0] == '\\') && (filename[1] == '\\')) {
|
||||||
|
|
||||||
else if ((filename[0] == '\\') && (filename[1] == '\\')) {
|
|
||||||
/* Find the machine and share name and rebuild the UNC */
|
/* Find the machine and share name and rebuild the UNC */
|
||||||
strlcpy(tmpbuf, filename, sizeof(tmpbuf));
|
strlcpy(tmpbuf, filename, sizeof(tmpbuf));
|
||||||
machinename = strtok(tmpbuf, "\\");
|
machinename = strtok(tmpbuf, "\\");
|
||||||
@ -85,13 +83,12 @@ is_ntfs(const char * file) {
|
|||||||
strlcat(drive, sharename, sizeof(drive));
|
strlcat(drive, sharename, sizeof(drive));
|
||||||
strlcat(drive, "\\", sizeof(drive));
|
strlcat(drive, "\\", sizeof(drive));
|
||||||
|
|
||||||
}
|
} else /* Not determinable */
|
||||||
else /* Not determinable */
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
GetVolumeInformation(drive, NULL, 0, NULL, 0, NULL, FSType,
|
GetVolumeInformation(drive, NULL, 0, NULL, 0, NULL, FSType,
|
||||||
sizeof(FSType));
|
sizeof(FSType));
|
||||||
if(strcmp(FSType,"NTFS") == 0)
|
if (strcmp(FSType, "NTFS") == 0)
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
else
|
else
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
@ -46,7 +46,7 @@ isc_ntpaths_init(void) {
|
|||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
BOOL keyFound = TRUE;
|
BOOL keyFound = TRUE;
|
||||||
|
|
||||||
memset(namedBase, 0, MAX_PATH);
|
memset(namedBase, 0, sizeof(namedBase));
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, BIND_SUBKEY, 0, KEY_READ, &hKey)
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, BIND_SUBKEY, 0, KEY_READ, &hKey)
|
||||||
!= ERROR_SUCCESS)
|
!= ERROR_SUCCESS)
|
||||||
keyFound = FALSE;
|
keyFound = FALSE;
|
||||||
@ -61,33 +61,35 @@ isc_ntpaths_init(void) {
|
|||||||
|
|
||||||
GetSystemDirectory(systemDir, MAX_PATH);
|
GetSystemDirectory(systemDir, MAX_PATH);
|
||||||
|
|
||||||
if (keyFound == FALSE)
|
if (keyFound == FALSE) {
|
||||||
/* Use the System Directory as a default */
|
/* Use the System Directory as a default */
|
||||||
strcpy(namedBase, systemDir);
|
strlcpy(namedBase, systemDir, sizeof(namedBase));
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(ns_confFile, namedBase);
|
strlcpy(ns_confFile, namedBase, sizeof(ns_confFile));
|
||||||
strcat(ns_confFile, "\\etc\\named.conf");
|
strlcat(ns_confFile, "\\etc\\named.conf", sizeof(ns_confFile));
|
||||||
|
|
||||||
strcpy(rndc_keyFile, namedBase);
|
strlcpy(rndc_keyFile, namedBase, sizeof(rndc_keyFile));
|
||||||
strcat(rndc_keyFile, "\\etc\\rndc.key");
|
strlcat(rndc_keyFile, "\\etc\\rndc.key", sizeof(rndc_keyFile));
|
||||||
|
|
||||||
strcpy(session_keyFile, namedBase);
|
strlcpy(session_keyFile, namedBase, sizeof(session_keyFile));
|
||||||
strcat(session_keyFile, "\\etc\\session.key");
|
strlcat(session_keyFile, "\\etc\\session.key", sizeof(session_keyFile));
|
||||||
|
|
||||||
strcpy(rndc_confFile, namedBase);
|
strlcpy(rndc_confFile, namedBase, sizeof(rndc_confFile));
|
||||||
strcat(rndc_confFile, "\\etc\\rndc.conf");
|
strlcat(rndc_confFile, "\\etc\\rndc.conf", sizeof(rndc_confFile));
|
||||||
|
|
||||||
strcpy(ns_defaultpidfile, namedBase);
|
strlcpy(ns_defaultpidfile, namedBase, sizeof(ns_defaultpidfile));
|
||||||
strcat(ns_defaultpidfile, "\\etc\\named.pid");
|
strlcat(ns_defaultpidfile, "\\etc\\named.pid",
|
||||||
|
sizeof(ns_defaultpidfile));
|
||||||
|
|
||||||
strcpy(ns_lockfile, namedBase);
|
strlcpy(ns_lockfile, namedBase, sizeof(ns_lockfile));
|
||||||
strcat(ns_lockfile, "\\etc\\named.lock");
|
strlcat(ns_lockfile, "\\etc\\named.lock", sizeof(ns_lockfile));
|
||||||
|
|
||||||
strcpy(local_state_dir, namedBase);
|
strlcpy(local_state_dir, namedBase, sizeof(local_state_dir));
|
||||||
strcat(local_state_dir, "\\bin");
|
strlcat(local_state_dir, "\\bin", sizeof(local_state_dir));
|
||||||
|
|
||||||
strcpy(sys_conf_dir, namedBase);
|
strlcpy(sys_conf_dir, namedBase, sizeof(sys_conf_dir));
|
||||||
strcat(sys_conf_dir, "\\etc");
|
strlcat(sys_conf_dir, "\\etc", sizeof(sys_conf_dir));
|
||||||
|
|
||||||
/* Added to avoid an assert on NULL value */
|
/* Added to avoid an assert on NULL value */
|
||||||
strlcpy(resolv_confFile, namedBase, sizeof(resolv_confFile));
|
strlcpy(resolv_confFile, namedBase, sizeof(resolv_confFile));
|
||||||
|
@ -3946,8 +3946,7 @@ isc__socket_setname(isc_socket_t *socket, const char *name, void *tag) {
|
|||||||
REQUIRE(VALID_SOCKET(socket));
|
REQUIRE(VALID_SOCKET(socket));
|
||||||
|
|
||||||
LOCK(&socket->lock);
|
LOCK(&socket->lock);
|
||||||
memset(socket->name, 0, sizeof(socket->name));
|
strlcpy(socket->name, name, sizeof(socket->name));
|
||||||
strncpy(socket->name, name, sizeof(socket->name) - 1);
|
|
||||||
socket->tag = tag;
|
socket->tag = tag;
|
||||||
UNLOCK(&socket->lock);
|
UNLOCK(&socket->lock);
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,7 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
|
|||||||
st.wMilliseconds);
|
st.wMilliseconds);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
strncpy(buf, "99-Bad-9999 99:99:99.999", len);
|
strlcpy(buf, "99-Bad-9999 99:99:99.999", len);
|
||||||
buf[len - 1] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,8 +395,7 @@ ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
|
|||||||
ifp->generation = mgr->generation;
|
ifp->generation = mgr->generation;
|
||||||
ifp->addr = *addr;
|
ifp->addr = *addr;
|
||||||
ifp->flags = 0;
|
ifp->flags = 0;
|
||||||
strncpy(ifp->name, name, sizeof(ifp->name));
|
strlcpy(ifp->name, name, sizeof(ifp->name));
|
||||||
ifp->name[sizeof(ifp->name)-1] = '\0';
|
|
||||||
ifp->clientmgr = NULL;
|
ifp->clientmgr = NULL;
|
||||||
|
|
||||||
result = isc_mutex_init(&ifp->lock);
|
result = isc_mutex_init(&ifp->lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user