Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
BIND
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
637
Issues
637
List
Boards
Labels
Service Desk
Milestones
Merge Requests
104
Merge Requests
104
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
BIND
Commits
cb629cde
Commit
cb629cde
authored
Sep 14, 2017
by
Mark Andrews
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more str{n}{cat,cpy} corrections rt45981_stage2
parent
bbe9f1dd
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
106 additions
and
127 deletions
+106
-127
bin/delv/delv.c
bin/delv/delv.c
+1
-2
bin/dig/dig.c
bin/dig/dig.c
+15
-30
bin/dig/host.c
bin/dig/host.c
+4
-8
bin/dig/nslookup.c
bin/dig/nslookup.c
+1
-2
bin/named/win32/ntservice.c
bin/named/win32/ntservice.c
+2
-2
bin/nsupdate/nsupdate.c
bin/nsupdate/nsupdate.c
+2
-2
bin/tests/sock_test.c
bin/tests/sock_test.c
+2
-2
bin/tools/mdig.c
bin/tools/mdig.c
+3
-6
lib/dns/rcode.c
lib/dns/rcode.c
+8
-4
lib/dns/rdata.c
lib/dns/rdata.c
+6
-2
lib/dns/ttl.c
lib/dns/ttl.c
+2
-2
lib/dns/zone.c
lib/dns/zone.c
+3
-4
lib/irs/getaddrinfo.c
lib/irs/getaddrinfo.c
+1
-2
lib/isc/mem.c
lib/isc/mem.c
+5
-7
lib/isc/pk11.c
lib/isc/pk11.c
+7
-3
lib/isc/task.c
lib/isc/task.c
+1
-2
lib/isc/unix/file.c
lib/isc/unix/file.c
+4
-3
lib/isc/unix/interfaceiter.c
lib/isc/unix/interfaceiter.c
+1
-1
lib/isc/unix/socket.c
lib/isc/unix/socket.c
+2
-3
lib/isc/unix/time.c
lib/isc/unix/time.c
+1
-2
lib/isc/win32/file.c
lib/isc/win32/file.c
+6
-5
lib/isc/win32/fsaccess.c
lib/isc/win32/fsaccess.c
+5
-8
lib/isc/win32/ntpaths.c
lib/isc/win32/ntpaths.c
+21
-19
lib/isc/win32/socket.c
lib/isc/win32/socket.c
+1
-2
lib/isc/win32/time.c
lib/isc/win32/time.c
+1
-2
lib/ns/interfacemgr.c
lib/ns/interfacemgr.c
+1
-2
No files found.
bin/delv/delv.c
View file @
cb629cde
...
...
@@ -978,8 +978,7 @@ plus_option(char *option) {
char
*
cmd
,
*
value
,
*
ptr
;
isc_boolean_t
state
=
ISC_TRUE
;
strncpy
(
option_store
,
option
,
sizeof
(
option_store
));
option_store
[
sizeof
(
option_store
)
-
1
]
=
0
;
strlcpy
(
option_store
,
option
,
sizeof
(
option_store
));
ptr
=
option_store
;
cmd
=
next_token
(
&
ptr
,
"="
);
if
(
cmd
==
NULL
)
{
...
...
bin/dig/dig.c
View file @
cb629cde
...
...
@@ -669,33 +669,27 @@ cleanup:
static
void
printgreeting
(
int
argc
,
char
**
argv
,
dig_lookup_t
*
lookup
)
{
int
i
;
size_t
remaining
;
static
isc_boolean_t
first
=
ISC_TRUE
;
char
append
[
MXNAME
];
if
(
printcmd
)
{
lookup
->
cmdline
[
sizeof
(
lookup
->
cmdline
)
-
1
]
=
0
;
snprintf
(
lookup
->
cmdline
,
sizeof
(
lookup
->
cmdline
),
"%s; <<>> DiG "
VERSION
" <<>>"
,
first
?
"
\n
"
:
""
);
i
=
1
;
while
(
i
<
argc
)
{
snprintf
(
append
,
sizeof
(
append
),
" %s"
,
argv
[
i
++
]);
remaining
=
sizeof
(
lookup
->
cmdline
)
-
strlen
(
lookup
->
cmdline
)
-
1
;
strncat
(
lookup
->
cmdline
,
append
,
remaining
);
strlcat
(
lookup
->
cmdline
,
append
,
sizeof
(
lookup
->
cmdline
));
}
remaining
=
sizeof
(
lookup
->
cmdline
)
-
strlen
(
lookup
->
cmdline
)
-
1
;
strncat
(
lookup
->
cmdline
,
"
\n
"
,
remaining
);
strlcat
(
lookup
->
cmdline
,
"
\n
"
,
sizeof
(
lookup
->
cmdline
));
if
(
first
&&
addresscount
!=
0
)
{
snprintf
(
append
,
sizeof
(
append
),
"; (%d server%s found)
\n
"
,
addresscount
,
addresscount
>
1
?
"s"
:
""
);
remaining
=
sizeof
(
lookup
->
cmdline
)
-
strlen
(
lookup
->
cmdline
)
-
1
;
strncat
(
lookup
->
cmdline
,
append
,
remaining
);
strlcat
(
lookup
->
cmdline
,
append
,
sizeof
(
lookup
->
cmdline
));
}
if
(
first
)
{
snprintf
(
append
,
sizeof
(
append
),
...
...
@@ -703,9 +697,8 @@ printgreeting(int argc, char **argv, dig_lookup_t *lookup) {
short_form
?
" +short"
:
""
,
printcmd
?
" +cmd"
:
""
);
first
=
ISC_FALSE
;
remaining
=
sizeof
(
lookup
->
cmdline
)
-
strlen
(
lookup
->
cmdline
)
-
1
;
strncat
(
lookup
->
cmdline
,
append
,
remaining
);
strlcat
(
lookup
->
cmdline
,
append
,
sizeof
(
lookup
->
cmdline
));
}
}
}
...
...
@@ -728,8 +721,7 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
isc_boolean_t
state
=
ISC_TRUE
;
size_t
n
;
strncpy
(
option_store
,
option
,
sizeof
(
option_store
));
option_store
[
sizeof
(
option_store
)
-
1
]
=
0
;
strlcpy
(
option_store
,
option
,
sizeof
(
option_store
));
ptr
=
option_store
;
cmd
=
next_token
(
&
ptr
,
"="
);
if
(
cmd
==
NULL
)
{
...
...
@@ -905,8 +897,7 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
goto
need_value
;
if
(
!
state
)
goto
invalid_option
;
strncpy
(
domainopt
,
value
,
sizeof
(
domainopt
));
domainopt
[
sizeof
(
domainopt
)
-
1
]
=
'\0'
;
strlcpy
(
domainopt
,
value
,
sizeof
(
domainopt
));
break
;
case
's'
:
/* dscp */
FULLCHECK
(
"dscp"
);
...
...
@@ -1598,8 +1589,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
batchname
=
value
;
return
(
value_from_next
);
case
'k'
:
strncpy
(
keyfile
,
value
,
sizeof
(
keyfile
));
keyfile
[
sizeof
(
keyfile
)
-
1
]
=
0
;
strlcpy
(
keyfile
,
value
,
sizeof
(
keyfile
));
return
(
value_from_next
);
case
'p'
:
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
,
ISC_TRUE
);
*
need_clone
=
ISC_TRUE
;
str
n
cpy
((
*
lookup
)
->
textname
,
value
,
str
l
cpy
((
*
lookup
)
->
textname
,
value
,
sizeof
((
*
lookup
)
->
textname
));
(
*
lookup
)
->
textname
[
sizeof
((
*
lookup
)
->
textname
)
-
1
]
=
0
;
(
*
lookup
)
->
trace_root
=
ISC_TF
((
*
lookup
)
->
trace
||
(
*
lookup
)
->
ns_search_only
);
(
*
lookup
)
->
new_search
=
ISC_TRUE
;
...
...
@@ -1699,10 +1688,8 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
#endif
digestbits
=
0
;
}
strncpy
(
keynametext
,
ptr
,
sizeof
(
keynametext
));
keynametext
[
sizeof
(
keynametext
)
-
1
]
=
0
;
strncpy
(
keysecret
,
ptr2
,
sizeof
(
keysecret
));
keysecret
[
sizeof
(
keysecret
)
-
1
]
=
0
;
strlcpy
(
keynametext
,
ptr
,
sizeof
(
keynametext
));
strlcpy
(
keysecret
,
ptr2
,
sizeof
(
keysecret
));
return
(
value_from_next
);
case
'x'
:
if
(
*
need_clone
)
...
...
@@ -1710,9 +1697,8 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
*
need_clone
=
ISC_TRUE
;
if
(
get_reverse
(
textname
,
sizeof
(
textname
),
value
,
ip6_int
,
ISC_FALSE
)
==
ISC_R_SUCCESS
)
{
str
n
cpy
((
*
lookup
)
->
textname
,
textname
,
str
l
cpy
((
*
lookup
)
->
textname
,
textname
,
sizeof
((
*
lookup
)
->
textname
));
(
*
lookup
)
->
textname
[
sizeof
((
*
lookup
)
->
textname
)
-
1
]
=
0
;
debug
(
"looking up %s"
,
(
*
lookup
)
->
textname
);
(
*
lookup
)
->
trace_root
=
ISC_TF
((
*
lookup
)
->
trace
||
(
*
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
,
ISC_TRUE
);
need_clone
=
ISC_TRUE
;
str
n
cpy
(
lookup
->
textname
,
rv
[
0
],
str
l
cpy
(
lookup
->
textname
,
rv
[
0
],
sizeof
(
lookup
->
textname
));
lookup
->
textname
[
sizeof
(
lookup
->
textname
)
-
1
]
=
0
;
lookup
->
trace_root
=
ISC_TF
(
lookup
->
trace
||
lookup
->
ns_search_only
);
lookup
->
new_search
=
ISC_TRUE
;
...
...
bin/dig/host.c
View file @
cb629cde
...
...
@@ -463,9 +463,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
dns_name_format
(
name
,
namestr
,
sizeof
(
namestr
));
lookup
=
clone_lookup
(
query
->
lookup
,
ISC_FALSE
);
if
(
lookup
!=
NULL
)
{
str
n
cpy
(
lookup
->
textname
,
namestr
,
str
l
cpy
(
lookup
->
textname
,
namestr
,
sizeof
(
lookup
->
textname
));
lookup
->
textname
[
sizeof
(
lookup
->
textname
)
-
1
]
=
0
;
lookup
->
rdtype
=
dns_rdatatype_aaaa
;
lookup
->
rdtypeset
=
ISC_TRUE
;
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
);
if
(
lookup
!=
NULL
)
{
str
n
cpy
(
lookup
->
textname
,
namestr
,
str
l
cpy
(
lookup
->
textname
,
namestr
,
sizeof
(
lookup
->
textname
));
lookup
->
textname
[
sizeof
(
lookup
->
textname
)
-
1
]
=
0
;
lookup
->
rdtype
=
dns_rdatatype_mx
;
lookup
->
rdtypeset
=
ISC_TRUE
;
lookup
->
origin
=
NULL
;
...
...
@@ -861,14 +859,12 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
lookup
->
pending
=
ISC_FALSE
;
if
(
get_reverse
(
store
,
sizeof
(
store
),
hostname
,
lookup
->
ip6_int
,
ISC_TRUE
)
==
ISC_R_SUCCESS
)
{
strncpy
(
lookup
->
textname
,
store
,
sizeof
(
lookup
->
textname
));
lookup
->
textname
[
sizeof
(
lookup
->
textname
)
-
1
]
=
0
;
strlcpy
(
lookup
->
textname
,
store
,
sizeof
(
lookup
->
textname
));
lookup
->
rdtype
=
dns_rdatatype_ptr
;
lookup
->
rdtypeset
=
ISC_TRUE
;
default_lookups
=
ISC_FALSE
;
}
else
{
strncpy
(
lookup
->
textname
,
hostname
,
sizeof
(
lookup
->
textname
));
lookup
->
textname
[
sizeof
(
lookup
->
textname
)
-
1
]
=
0
;
strlcpy
(
lookup
->
textname
,
hostname
,
sizeof
(
lookup
->
textname
));
usesearch
=
ISC_TRUE
;
}
lookup
->
new_search
=
ISC_TRUE
;
...
...
bin/dig/nslookup.c
View file @
cb629cde
...
...
@@ -479,9 +479,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
dns_name_format
(
name
,
namestr
,
sizeof
(
namestr
));
lookup
=
clone_lookup
(
query
->
lookup
,
ISC_FALSE
);
if
(
lookup
!=
NULL
)
{
str
n
cpy
(
lookup
->
textname
,
namestr
,
str
l
cpy
(
lookup
->
textname
,
namestr
,
sizeof
(
lookup
->
textname
));
lookup
->
textname
[
sizeof
(
lookup
->
textname
)
-
1
]
=
0
;
lookup
->
rdtype
=
dns_rdatatype_aaaa
;
lookup
->
rdtypeset
=
ISC_TRUE
;
lookup
->
origin
=
NULL
;
...
...
bin/named/win32/ntservice.c
View file @
cb629cde
...
...
@@ -49,8 +49,8 @@ ntservice_init(void) {
}
UpdateSCM
(
SERVICE_RUNNING
);
}
else
{
str
cpy
(
ConsoleTitle
,
"BIND Version "
);
str
cat
(
ConsoleTitle
,
VERSION
);
str
lcpy
(
ConsoleTitle
,
"BIND Version "
,
sizeof
(
ConsoleTitle
)
);
str
lcat
(
ConsoleTitle
,
VERSION
,
sizeof
(
ConsoleTitle
)
);
SetConsoleTitle
(
ConsoleTitle
);
}
}
...
...
bin/nsupdate/nsupdate.c
View file @
cb629cde
...
...
@@ -453,8 +453,8 @@ parse_hmac(const dns_name_t **hmac, const char *hmacstr, size_t len,
return
(
ISC_FALSE
);
}
strncpy
(
buf
,
hmacstr
,
len
);
buf
[
len
]
=
0
;
/* Copy len bytes and NUL terminate. */
strlcpy
(
buf
,
hmacstr
,
ISC_MIN
(
len
+
1
,
sizeof
(
buf
)))
;
#ifndef PK11_MD5_DISABLE
if
(
strcasecmp
(
buf
,
"hmac-md5"
)
==
0
)
{
...
...
bin/tests/sock_test.c
View file @
cb629cde
...
...
@@ -106,7 +106,7 @@ my_recv(isc_task_t *task, isc_event_t *event) {
region
.
base
=
isc_mem_get
(
mctx
,
strlen
(
buf
)
+
1
);
if
(
region
.
base
!=
NULL
)
{
region
.
length
=
strlen
(
buf
)
+
1
;
str
cpy
((
char
*
)
region
.
base
,
buf
);
/* strcpy is safe */
str
lcpy
((
char
*
)
region
.
base
,
buf
,
region
.
length
);
}
else
region
.
length
=
0
;
isc_socket_send
(
sock
,
&
region
,
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
);
if
(
region
.
base
!=
NULL
)
{
region
.
length
=
strlen
(
buf
)
+
1
;
str
cpy
((
char
*
)
region
.
base
,
buf
);
/* This strcpy is safe. */
str
lcpy
((
char
*
)
region
.
base
,
buf
,
region
.
length
);
}
else
{
region
.
length
=
0
;
}
...
...
bin/tools/mdig.c
View file @
cb629cde
...
...
@@ -1041,8 +1041,7 @@ plus_option(char *option, struct query *query, isc_boolean_t global)
isc_boolean_t
state
=
ISC_TRUE
;
size_t
n
;
strncpy
(
option_store
,
option
,
sizeof
(
option_store
));
option_store
[
sizeof
(
option_store
)
-
1
]
=
0
;
strlcpy
(
option_store
,
option
,
sizeof
(
option_store
));
ptr
=
option_store
;
cmd
=
next_token
(
&
ptr
,
"="
);
if
(
cmd
==
NULL
)
{
...
...
@@ -1657,8 +1656,7 @@ dash_option(const char *option, char *next, struct query *query,
return
(
value_from_next
);
case
'x'
:
get_reverse
(
textname
,
sizeof
(
textname
),
value
,
query
->
ip6_int
);
strncpy
(
query
->
textname
,
textname
,
sizeof
(
query
->
textname
));
query
->
textname
[
sizeof
(
query
->
textname
)
-
1
]
=
0
;
strlcpy
(
query
->
textname
,
textname
,
sizeof
(
query
->
textname
));
query
->
rdtype
=
dns_rdatatype_ptr
;
query
->
rdclass
=
dns_rdataclass_in
;
*
setname
=
ISC_TRUE
;
...
...
@@ -1845,9 +1843,8 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv)
*/
if
(
query
==
&
default_query
)
query
=
clone_default_query
();
str
n
cpy
(
query
->
textname
,
rv
[
0
],
str
l
cpy
(
query
->
textname
,
rv
[
0
],
sizeof
(
query
->
textname
));
query
->
textname
[
sizeof
(
query
->
textname
)
-
1
]
=
0
;
ISC_LIST_APPEND
(
queries
,
query
,
link
);
query
=
clone_default_query
();
...
...
lib/dns/rcode.c
View file @
cb629cde
...
...
@@ -252,8 +252,8 @@ maybe_numeric(unsigned int *valuep, isc_textregion_t *source,
* isc_parse_uint32(). isc_parse_uint32() requires
* null termination, so we must make a copy.
*/
str
ncpy
(
buffer
,
source
->
base
,
sizeof
(
buffer
));
buffer
[
sizeof
(
buffer
)
-
1
]
=
'\0'
;
str
lcpy
(
buffer
,
source
->
base
,
ISC_MIN
(
source
->
length
+
1
,
sizeof
(
buffer
)))
;
INSIST
(
buffer
[
source
->
length
]
==
'\0'
);
...
...
@@ -504,8 +504,12 @@ dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
char
*
endp
;
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
);
if
(
*
endp
==
'\0'
&&
val
<=
0xffff
)
{
*
classp
=
(
dns_rdataclass_t
)
val
;
...
...
lib/dns/rdata.c
View file @
cb629cde
...
...
@@ -1339,8 +1339,12 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
char
*
endp
;
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
);
if
(
*
endp
==
'\0'
&&
val
<=
0xffff
)
{
*
typep
=
(
dns_rdatatype_t
)
val
;
...
...
lib/dns/ttl.c
View file @
cb629cde
...
...
@@ -159,8 +159,8 @@ bind_ttl(isc_textregion_t *source, isc_uint32_t *ttl) {
*/
if
(
source
->
length
>
sizeof
(
buf
)
-
1
)
return
(
DNS_R_SYNTAX
);
strncpy
(
buf
,
source
->
base
,
source
->
length
);
buf
[
source
->
length
]
=
'\0'
;
/* Copy source->length bytes and NUL terminate. */
strlcpy
(
buf
,
source
->
base
,
ISC_MIN
(
source
->
length
+
1
,
sizeof
(
buf
)))
;
s
=
buf
;
do
{
...
...
lib/dns/zone.c
View file @
cb629cde
...
...
@@ -1372,7 +1372,7 @@ dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx) {
unsigned int i;
isc_result_t result = ISC_R_SUCCESS;
void *mem;
char **tmp, *tmp2;
char **tmp, *tmp2
, *base
;
REQUIRE(DNS_ZONE_VALID(zone));
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;
mem = isc_mem_allocate(mctx, size);
if (mem != NULL) {
size_t remaining;
tmp = mem;
tmp2 = mem;
base = mem;
tmp2 += (zone->db_argc + 1) * sizeof(char *);
for (i = 0; i < zone->db_argc; i++) {
remaining = size - (tmp2 - (char *) mem);
*tmp++ = tmp2;
strlcpy(tmp2, zone->db_argv[i],
remaining
);
strlcpy(tmp2, zone->db_argv[i],
size - (tmp2 - base)
);
tmp2 += strlen(tmp2) + 1;
}
*tmp = NULL;
...
...
lib/irs/getaddrinfo.c
View file @
cb629cde
...
...
@@ -374,8 +374,7 @@ getaddrinfo(const char *hostname, const char *servname,
*/
ntmp
[
0
]
=
'\0'
;
if
(
strchr
(
hostname
,
'%'
)
!=
NULL
)
{
strncpy
(
ntmp
,
hostname
,
sizeof
(
ntmp
)
-
1
);
ntmp
[
sizeof
(
ntmp
)
-
1
]
=
'\0'
;
strlcpy
(
ntmp
,
hostname
,
sizeof
(
ntmp
));
p
=
strchr
(
ntmp
,
'%'
);
ep
=
NULL
;
...
...
lib/isc/mem.c
View file @
cb629cde
...
...
@@ -1671,12 +1671,12 @@ isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
REQUIRE
(
VALID_CONTEXT
(
mctx
));
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
)
str
ncpy
(
ns
,
s
,
len
+
1
);
str
lcpy
(
ns
,
s
,
len
);
return
(
ns
);
}
...
...
@@ -1827,8 +1827,7 @@ isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
REQUIRE
(
VALID_CONTEXT
(
ctx
));
LOCK
(
&
ctx
->
lock
);
memset
(
ctx
->
name
,
0
,
sizeof
(
ctx
->
name
));
strncpy
(
ctx
->
name
,
name
,
sizeof
(
ctx
->
name
)
-
1
);
strlcpy
(
ctx
->
name
,
name
,
sizeof
(
ctx
->
name
));
ctx
->
tag
=
tag
;
UNLOCK
(
&
ctx
->
lock
);
}
...
...
@@ -1913,8 +1912,7 @@ isc__mempool_setname(isc_mempool_t *mpctx0, const char *name) {
if
(
mpctx
->
lock
!=
NULL
)
LOCK
(
mpctx
->
lock
);
strncpy
(
mpctx
->
name
,
name
,
sizeof
(
mpctx
->
name
)
-
1
);
mpctx
->
name
[
sizeof
(
mpctx
->
name
)
-
1
]
=
'\0'
;
strlcpy
(
mpctx
->
name
,
name
,
sizeof
(
mpctx
->
name
));
if
(
mpctx
->
lock
!=
NULL
)
UNLOCK
(
mpctx
->
lock
);
...
...
lib/isc/pk11.c
View file @
cb629cde
...
...
@@ -408,9 +408,13 @@ pk11_get_session(pk11_context_t *ctx, pk11_optype_t optype,
/* Override the token's PIN */
if
(
logon
&&
pin
!=
NULL
&&
*
pin
!=
'\0'
)
{
if
(
strlen
(
pin
)
>
PINLEN
)
return
ISC_R_RANGE
;
memset
(
token
->
pin
,
0
,
PINLEN
+
1
);
strncpy
(
token
->
pin
,
pin
,
PINLEN
);
return
(
ISC_R_RANGE
);
/*
* 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
;
...
...
lib/isc/task.c
View file @
cb629cde
...
...
@@ -882,8 +882,7 @@ isc__task_setname(isc_task_t *task0, const char *name, void *tag) {
REQUIRE
(
VALID_TASK
(
task
));
LOCK
(
&
task
->
lock
);
memset
(
task
->
name
,
0
,
sizeof
(
task
->
name
));
strncpy
(
task
->
name
,
name
,
sizeof
(
task
->
name
)
-
1
);
strlcpy
(
task
->
name
,
name
,
sizeof
(
task
->
name
));
task
->
tag
=
tag
;
UNLOCK
(
&
task
->
lock
);
}
...
...
lib/isc/unix/file.c
View file @
cb629cde
...
...
@@ -234,11 +234,12 @@ isc_file_template(const char *path, const char *templet, char *buf,
s
=
strrchr
(
path
,
'/'
);
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
);
strncpy
(
buf
,
path
,
s
-
path
+
1
);
buf
[
s
-
path
+
1
]
=
'\0'
;
/* Copy 'prefixlen' bytes and NUL terminate. */
strlcpy
(
buf
,
path
,
ISC_MIN
(
prefixlen
+
1
,
buflen
))
;
strlcat
(
buf
,
templet
,
buflen
);
}
else
{
if
((
strlen
(
templet
)
+
1
)
>
buflen
)
...
...
lib/isc/unix/interfaceiter.c
View file @
cb629cde
...
...
@@ -229,7 +229,7 @@ linux_if_inet6_current(isc_interfaceiter_t *iter) {
}
}
isc_netaddr_fromin6
(
&
iter
->
current
.
netmask
,
&
addr6
);
str
n
cpy
(
iter
->
current
.
name
,
name
,
sizeof
(
iter
->
current
.
name
));
str
l
cpy
(
iter
->
current
.
name
,
name
,
sizeof
(
iter
->
current
.
name
));
return
(
ISC_R_SUCCESS
);
}
#endif
...
...
lib/isc/unix/socket.c
View file @
cb629cde
...
...
@@ -5634,7 +5634,7 @@ isc__socket_filter(isc_socket_t *sock0, const char *filter) {
#if defined(SO_ACCEPTFILTER) && defined(ENABLE_ACCEPTFILTER)
bzero
(
&
afa
,
sizeof
(
afa
));
str
n
cpy
(
afa
.
af_name
,
filter
,
sizeof
(
afa
.
af_name
));
str
l
cpy
(
afa
.
af_name
,
filter
,
sizeof
(
afa
.
af_name
));
if
(
setsockopt
(
sock
->
fd
,
SOL_SOCKET
,
SO_ACCEPTFILTER
,
&
afa
,
sizeof
(
afa
))
==
-
1
)
{
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
));
LOCK
(
&
sock
->
lock
);
memset
(
sock
->
name
,
0
,
sizeof
(
sock
->
name
));
strncpy
(
sock
->
name
,
name
,
sizeof
(
sock
->
name
)
-
1
);
strlcpy
(
sock
->
name
,
name
,
sizeof
(
sock
->
name
));
sock
->
tag
=
tag
;
UNLOCK
(
&
sock
->
lock
);
}
...
...
lib/isc/unix/time.c
View file @
cb629cde
...
...
@@ -394,8 +394,7 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
snprintf
(
buf
+
flen
,
len
-
flen
,
".%03u"
,
t
->
nanoseconds
/
NS_PER_MS
);
else
{
strncpy
(
buf
,
"99-Bad-9999 99:99:99.999"
,
len
);
buf
[
len
-
1
]
=
0
;
strlcpy
(
buf
,
"99-Bad-9999 99:99:99.999"
,
len
);
}
}
...
...
lib/isc/win32/file.c
View file @
cb629cde
...
...
@@ -334,11 +334,12 @@ isc_file_template(const char *path, const char *templet, char *buf,
s
=
strrchr
(
path
,
'\\'
);
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
);
strncpy
(
buf
,
path
,
s
-
path
+
1
);
buf
[
s
-
path
+
1
]
=
'\0'
;
/* Copy 'prefixlen' bytes and NUL terminate. */
strlcpy
(
buf
,
path
,
ISC_MIN
(
prefixlen
+
1
,
buflen
))
;
strlcat
(
buf
,
templet
,
buflen
);
}
else
{
if
((
strlen
(
templet
)
+
1
)
>
buflen
)
...
...
@@ -616,8 +617,8 @@ isc_file_progname(const char *filename, char *progname, size_t namelen) {
if
(
len
>=
namelen
)
return
(
ISC_R_NOSPACE
);
strlcpy
(
progname
,
s
,
len
);
progname
[
len
]
=
'\0'
;
/* Copy up to 'len' bytes and NUL terminate. */
strlcpy
(
progname
,
s
,
ISC_MIN
(
len
+
1
,
namelen
))
;
return
(
ISC_R_SUCCESS
);
}
...
...
lib/isc/win32/fsaccess.c
View file @
cb629cde
...
...
@@ -70,11 +70,9 @@ is_ntfs(const char * file) {
*/
if
(
isalpha
(
filename
[
0
])
&&
filename
[
1
]
==
':'
&&
(
filename
[
2
]
==
'\\'
||
filename
[
2
]
==
'/'
))
{
strncpy
(
drive
,
filename
,
3
);
drive
[
3
]
=
'\0'
;
}
else
if
((
filename
[
0
]
==
'\\'
)
&&
(
filename
[
1
]
==
'\\'
))
{
/* Copy 'c:\' or 'c:/' and NUL terminate. */
strlcpy
(
drive
,
filename
,
ISC_MIN
(
3
+
1
,
sizeof
(
drive
)));
}
else
if
((
filename
[
0
]
==
'\\'
)
&&
(
filename
[
1
]
==
'\\'
))
{
/* Find the machine and share name and rebuild the UNC */
strlcpy
(
tmpbuf
,
filename
,
sizeof
(
tmpbuf
));
machinename
=
strtok
(
tmpbuf
,
"
\\
"
);
...
...
@@ -85,13 +83,12 @@ is_ntfs(const char * file) {
strlcat
(
drive
,
sharename
,
sizeof
(
drive
));
strlcat
(
drive
,
"
\\
"
,
sizeof
(
drive
));
}
else
/* Not determinable */
}
else
/* Not determinable */
return
(
FALSE
);
GetVolumeInformation
(
drive
,
NULL
,
0
,
NULL
,
0
,
NULL
,
FSType
,
sizeof
(
FSType
));
if
(
strcmp
(
FSType
,
"NTFS"
)
==
0
)
if
(
strcmp
(
FSType
,
"NTFS"
)
==
0
)
return
(
TRUE
);
else
return
(
FALSE
);
...
...
lib/isc/win32/ntpaths.c
View file @
cb629cde
...
...
@@ -46,7 +46,7 @@ isc_ntpaths_init(void) {
HKEY
hKey
;
BOOL
keyFound
=
TRUE
;
memset
(
namedBase
,
0
,
MAX_PATH
);
memset
(
namedBase
,
0
,
sizeof
(
namedBase
)
);
if
(
RegOpenKeyEx
(
HKEY_LOCAL_MACHINE
,
BIND_SUBKEY
,
0
,
KEY_READ
,
&
hKey
)
!=
ERROR_SUCCESS
)
keyFound
=
FALSE
;
...
...
@@ -61,33 +61,35 @@ isc_ntpaths_init(void) {
GetSystemDirectory
(
systemDir
,
MAX_PATH
);
if
(
keyFound
==
FALSE
)
if
(
keyFound
==
FALSE
)
{
/* Use the System Directory as a default */
strcpy
(
namedBase
,
systemDir
);
strlcpy
(
namedBase
,
systemDir
,
sizeof
(
namedBase
));
}
str
cpy
(
ns_confFile
,
namedBase
);
str
cat
(
ns_confFile
,
"
\\
etc
\\
named.conf"
);
str
lcpy
(
ns_confFile
,
namedBase
,
sizeof
(
ns_confFile
)
);
str
lcat
(
ns_confFile
,
"
\\
etc
\\
named.conf"
,
sizeof
(
ns_confFile
)
);
str
cpy
(
rndc_keyFile
,
namedBase
);
str
cat
(
rndc_keyFile
,
"
\\
etc
\\
rndc.key"
);
str
lcpy
(
rndc_keyFile
,
namedBase
,
sizeof
(
rndc_keyFile
)
);
str
lcat
(
rndc_keyFile
,
"
\\
etc
\\
rndc.key"
,
sizeof
(
rndc_keyFile
)
);
str
cpy
(
session_keyFile
,
namedBase
);
str
cat
(
session_keyFile
,
"
\\
etc
\\
session.key"
);
str
lcpy
(
session_keyFile
,
namedBase
,
sizeof
(
session_keyFile
)
);
str
lcat
(
session_keyFile
,
"
\\
etc
\\
session.key"
,
sizeof
(
session_keyFile
)
);
str
cpy
(
rndc_confFile
,
namedBase
);
str
cat
(
rndc_confFile
,
"
\\
etc
\\
rndc.conf"
);
str
lcpy
(
rndc_confFile
,
namedBase
,
sizeof
(
rndc_confFile
)
);
str
lcat
(
rndc_confFile
,
"
\\
etc
\\
rndc.conf"
,
sizeof
(
rndc_confFile
)
);
strcpy
(
ns_defaultpidfile
,
namedBase
);
strcat
(
ns_defaultpidfile
,
"
\\
etc
\\
named.pid"
);
strlcpy
(
ns_defaultpidfile
,
namedBase
,
sizeof
(
ns_defaultpidfile
));
strlcat
(
ns_defaultpidfile
,
"
\\
etc
\\
named.pid"
,
sizeof
(
ns_defaultpidfile
));
str
cpy
(
ns_lockfile
,
namedBase
);
str
cat
(
ns_lockfile
,
"
\\
etc
\\
named.lock"
);
str
lcpy
(
ns_lockfile
,
namedBase
,
sizeof
(
ns_lockfile
)
);
str
lcat
(
ns_lockfile
,
"
\\
etc
\\
named.lock"
,
sizeof
(
ns_lockfile
)
);
str
cpy
(
local_state_dir
,
namedBase
);
str
cat
(
local_state_dir
,
"
\\
bin"
);
str
lcpy
(
local_state_dir
,
namedBase
,
sizeof
(
local_state_dir
)
);
str
lcat
(
local_state_dir
,
"
\\
bin"
,
sizeof
(
local_state_dir
)
);
str
cpy
(
sys_conf_dir
,
namedBase
);
str
cat
(
sys_conf_dir
,
"
\\
etc"
);
str
lcpy
(
sys_conf_dir
,
namedBase
,
sizeof
(
sys_conf_dir
)
);
str
lcat
(