Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
a009d03a
Commit
a009d03a
authored
Oct 03, 2017
by
Mark Andrews
Browse files
4748. [cleanup] Sprintf to snprintf coversions. [RT #46132]
parent
7cb14b61
Changes
55
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
a009d03a
4748. [cleanup] Sprintf to snprintf coversions. [RT #46132]
4747. [func] Synthesis of responses from DNSSEC-verified records.
Stage 3 - synthesize NODATA responses. [RT #40138]
...
...
bin/dnssec/dnssec-signzone.c
View file @
a009d03a
...
...
@@ -2813,7 +2813,7 @@ writeset(const char *prefix, dns_rdatatype_t type) {
if
(
filename
==
NULL
)
fatal
(
"out of memory"
);
if
(
dsdir
!=
NULL
)
sprintf
(
filename
,
"%s/"
,
dsdir
);
s
n
printf
(
filename
,
filenamelen
,
"%s/"
,
dsdir
);
else
filename
[
0
]
=
0
;
strlcat
(
filename
,
prefix
,
filenamelen
);
...
...
@@ -3490,12 +3490,13 @@ main(int argc, char *argv[]) {
origin
=
file
;
if
(
output
==
NULL
)
{
size_t
size
;
free_output
=
ISC_TRUE
;
output
=
isc_mem_allocate
(
mctx
,
strlen
(
file
)
+
strlen
(
".signed"
)
+
1
);
size
=
strlen
(
file
)
+
strlen
(
".signed"
)
+
1
;
output
=
isc_mem_allocate
(
mctx
,
size
);
if
(
output
==
NULL
)
fatal
(
"out of memory"
);
sprintf
(
output
,
"%s.signed"
,
file
);
s
n
printf
(
output
,
size
,
"%s.signed"
,
file
);
}
if
(
inputformatstr
!=
NULL
)
{
...
...
bin/named/server.c
View file @
a009d03a
...
...
@@ -1790,8 +1790,8 @@ dns64_reverse(dns_view_t *view, isc_mem_t *mctx, isc_netaddr_t *na,
unsigned
int
prefixlen
,
const
char
*
server
,
const
char
*
contact
)
{
char
*
cp
;
char
reverse
[
48
+
sizeof
(
"ip6.arpa
."
)];
char
reverse
[
48
+
sizeof
(
"ip6.arpa."
)]
=
{
0
}
;
char
buf
[
sizeof
(
"x.x
."
)];
const
char
*
dns64_dbtype
[
4
]
=
{
"_dns64"
,
"dns64"
,
"."
,
"."
};
const
char
*
sep
=
": view "
;
const
char
*
viewname
=
view
->
name
;
...
...
@@ -1814,15 +1814,13 @@ dns64_reverse(dns_view_t *view, isc_mem_t *mctx, isc_netaddr_t *na,
/*
* Construct the reverse name of the zone.
*/
cp
=
reverse
;
s6
=
na
->
type
.
in6
.
s6_addr
;
while
(
prefixlen
>
0
)
{
prefixlen
-=
8
;
sprintf
(
cp
,
"%x.%x."
,
s6
[
prefixlen
/
8
]
&
0xf
,
(
s6
[
prefixlen
/
8
]
>>
4
)
&
0xf
);
cp
+=
4
;
s
n
printf
(
buf
,
sizeof
(
buf
)
,
"%x.%x."
,
s6
[
prefixlen
/
8
]
&
0xf
,
(
s6
[
prefixlen
/
8
]
>>
4
)
&
0xf
);
strlcat
(
reverse
,
buf
,
sizeof
(
reverse
))
;
}
strlcat
(
reverse
,
"ip6.arpa."
,
sizeof
(
reverse
));
/*
...
...
bin/named/statschannel.c
View file @
a009d03a
...
...
@@ -1270,8 +1270,8 @@ rdatasetstats_dump(dns_rdatastatstype_t type, isc_uint64_t val, void *arg) {
case
isc_statsformat_json
:
#ifdef HAVE_JSON
zoneobj
=
(
json_object
*
)
dumparg
->
arg
;
sprintf
(
buf
,
"%s%s%s"
,
stale
?
"#"
:
"
"
,
nxrrset
?
"!"
:
""
,
typestr
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%s%s%s
"
,
stale
?
"#"
:
""
,
nxrrset
?
"!"
:
""
,
typestr
);
obj
=
json_object_new_int64
(
val
);
if
(
obj
==
NULL
)
return
;
...
...
bin/tests/nsecify.c
View file @
a009d03a
...
...
@@ -179,7 +179,7 @@ nsecify(char *filename) {
len
=
strlen
(
filename
);
if
(
len
+
4
+
1
>
sizeof
(
newfilename
))
fatal
(
"filename too long"
);
sprintf
(
newfilename
,
"%s.new"
,
filename
);
s
n
printf
(
newfilename
,
sizeof
(
newfilename
),
"%s.new"
,
filename
);
result
=
dns_db_dump
(
db
,
NULL
,
newfilename
);
check_result
(
result
,
"dns_db_dump"
);
dns_db_detach
(
&
db
);
...
...
bin/tests/rwlock_test.c
View file @
a009d03a
...
...
@@ -109,7 +109,7 @@ main(int argc, char *argv[]) {
RUNTIME_CHECK
(
isc_rwlock_init
(
&
lock
,
5
,
10
)
==
ISC_R_SUCCESS
);
for
(
i
=
0
;
i
<
nworkers
;
i
++
)
{
sprintf
(
name
,
"%02u"
,
i
);
s
n
printf
(
name
,
sizeof
(
name
),
"%02u"
,
i
);
dupname
=
strdup
(
name
);
RUNTIME_CHECK
(
dupname
!=
NULL
);
if
(
i
!=
0
&&
i
%
3
==
0
)
...
...
bin/tests/sock_test.c
View file @
a009d03a
...
...
@@ -102,8 +102,8 @@ my_recv(isc_task_t *task, isc_event_t *event) {
*/
if
(
strcmp
(
event
->
ev_arg
,
"so2"
)
!=
0
)
{
region
=
dev
->
region
;
sprintf
(
buf
,
"
\r\n
Received: %.*s
\r\n\r\n
"
,
(
int
)
dev
->
n
,
(
char
*
)
region
.
base
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"
\r\n
Received: %.*s
\r\n\r\n
"
,
(
int
)
dev
->
n
,
(
char
*
)
region
.
base
);
region
.
base
=
isc_mem_get
(
mctx
,
strlen
(
buf
)
+
1
);
if
(
region
.
base
!=
NULL
)
{
region
.
length
=
strlen
(
buf
)
+
1
;
...
...
lib/dns/dst_api.c
View file @
a009d03a
...
...
@@ -1878,8 +1878,9 @@ buildfilename(dns_name_t *name, dns_keytag_t id,
len
=
1
+
3
+
1
+
5
+
strlen
(
suffix
)
+
1
;
if
(
isc_buffer_availablelength
(
out
)
<
len
)
return
(
ISC_R_NOSPACE
);
sprintf
((
char
*
)
isc_buffer_used
(
out
),
"+%03d+%05d%s"
,
alg
,
id
,
suffix
);
snprintf
((
char
*
)
isc_buffer_used
(
out
),
(
int
)
isc_buffer_availablelength
(
out
),
"+%03d+%05d%s"
,
alg
,
id
,
suffix
);
isc_buffer_add
(
out
,
len
);
return
(
ISC_R_SUCCESS
);
...
...
lib/dns/gssapictx.c
View file @
a009d03a
...
...
@@ -695,10 +695,14 @@ dst_gssapi_acceptctx(gss_cred_id_t cred,
*/
const
char
*
old
=
getenv
(
"KRB5_KTNAME"
);
if
(
old
==
NULL
||
strcmp
(
old
,
gssapi_keytab
)
!=
0
)
{
char
*
kt
=
malloc
(
strlen
(
gssapi_keytab
)
+
13
);
size_t
size
;
char
*
kt
;
size
=
strlen
(
gssapi_keytab
)
+
13
;
kt
=
malloc
(
size
);
if
(
kt
==
NULL
)
return
(
ISC_R_NOMEMORY
);
sprintf
(
kt
,
"KRB5_KTNAME=%s"
,
gssapi_keytab
);
s
n
printf
(
kt
,
size
,
"KRB5_KTNAME=%s"
,
gssapi_keytab
);
if
(
putenv
(
kt
)
!=
0
)
return
(
ISC_R_NOMEMORY
);
}
...
...
lib/dns/private.c
View file @
a009d03a
...
...
@@ -351,7 +351,7 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) {
isc_buffer_putstr
(
buf
,
"Signing with "
);
dns_secalg_format
(
alg
,
algbuf
,
sizeof
(
algbuf
));
sprintf
(
keybuf
,
"key %d/%s"
,
keyid
,
algbuf
);
s
n
printf
(
keybuf
,
sizeof
(
keybuf
),
"key %d/%s"
,
keyid
,
algbuf
);
isc_buffer_putstr
(
buf
,
keybuf
);
}
else
return
(
ISC_R_NOTFOUND
);
...
...
lib/dns/rdata.c
View file @
a009d03a
...
...
@@ -522,7 +522,7 @@ typemap_totext(isc_region_t *sr, dns_rdata_textctx_t *tctx,
RETERR
(
dns_rdatatype_totext
(
t
,
target
));
}
else
{
char
buf
[
sizeof
(
"TYPE65535"
)];
sprintf
(
buf
,
"TYPE%u"
,
t
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"TYPE%u"
,
t
);
RETERR
(
str_totext
(
buf
,
target
));
}
}
...
...
lib/dns/rdata/any_255/tsig_250.c
View file @
a009d03a
...
...
@@ -174,7 +174,7 @@ totext_any_tsig(ARGS_TOTEXT) {
*/
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u "
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
@@ -182,7 +182,7 @@ totext_any_tsig(ARGS_TOTEXT) {
*/
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u"
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u"
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
@@ -210,7 +210,7 @@ totext_any_tsig(ARGS_TOTEXT) {
*/
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u "
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
@@ -225,7 +225,7 @@ totext_any_tsig(ARGS_TOTEXT) {
*/
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
" %u "
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
" %u "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
lib/dns/rdata/ch_3/a_1.c
View file @
a009d03a
...
...
@@ -80,7 +80,7 @@ totext_ch_a(ARGS_TOTEXT) {
sub
=
name_prefix
(
&
name
,
tctx
->
origin
,
&
prefix
);
RETERR
(
dns_name_totext
(
&
prefix
,
sub
,
target
));
sprintf
(
buf
,
"%o"
,
addr
);
/* note octal */
s
n
printf
(
buf
,
sizeof
(
buf
),
"%o"
,
addr
);
/* note octal */
RETERR
(
str_totext
(
" "
,
target
));
return
(
str_totext
(
buf
,
target
));
}
...
...
lib/dns/rdata/generic/afsdb_18.c
View file @
a009d03a
...
...
@@ -77,7 +77,7 @@ totext_afsdb(ARGS_TOTEXT) {
dns_rdata_toregion
(
rdata
,
&
region
);
num
=
uint16_fromregion
(
&
region
);
isc_region_consume
(
&
region
,
2
);
sprintf
(
buf
,
"%u "
,
num
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
num
);
RETERR
(
str_totext
(
buf
,
target
));
dns_name_fromregion
(
&
name
,
&
region
);
sub
=
name_prefix
(
&
name
,
tctx
->
origin
,
&
prefix
);
...
...
lib/dns/rdata/generic/cert_37.c
View file @
a009d03a
...
...
@@ -85,7 +85,7 @@ totext_cert(ARGS_TOTEXT) {
*/
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u "
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
lib/dns/rdata/generic/csync_62.c
View file @
a009d03a
...
...
@@ -56,14 +56,14 @@ totext_csync(ARGS_TOTEXT) {
num
=
uint32_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
4
);
sprintf
(
buf
,
"%lu"
,
num
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%lu"
,
num
);
RETERR
(
str_totext
(
buf
,
target
));
RETERR
(
str_totext
(
" "
,
target
));
num
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%lu"
,
num
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%lu"
,
num
);
RETERR
(
str_totext
(
buf
,
target
));
return
(
typemap_totext
(
&
sr
,
NULL
,
target
));
...
...
lib/dns/rdata/generic/ds_43.c
View file @
a009d03a
...
...
@@ -111,7 +111,7 @@ generic_totext_ds(ARGS_TOTEXT) {
*/
n
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u "
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
@@ -119,7 +119,7 @@ generic_totext_ds(ARGS_TOTEXT) {
*/
n
=
uint8_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
1
);
sprintf
(
buf
,
"%u "
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
@@ -127,7 +127,7 @@ generic_totext_ds(ARGS_TOTEXT) {
*/
n
=
uint8_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
1
);
sprintf
(
buf
,
"%u"
,
n
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u"
,
n
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
lib/dns/rdata/generic/hip_55.c
View file @
a009d03a
...
...
@@ -140,7 +140,7 @@ totext_hip(ARGS_TOTEXT) {
/*
* Algorithm
*/
sprintf
(
buf
,
"%u "
,
algorithm
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
algorithm
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
lib/dns/rdata/generic/ipseckey_45.c
View file @
a009d03a
...
...
@@ -134,7 +134,7 @@ totext_ipseckey(ARGS_TOTEXT) {
dns_rdata_toregion
(
rdata
,
&
region
);
num
=
uint8_fromregion
(
&
region
);
isc_region_consume
(
&
region
,
1
);
sprintf
(
buf
,
"%u "
,
num
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
num
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
@@ -142,7 +142,7 @@ totext_ipseckey(ARGS_TOTEXT) {
*/
gateway
=
uint8_fromregion
(
&
region
);
isc_region_consume
(
&
region
,
1
);
sprintf
(
buf
,
"%u "
,
gateway
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
gateway
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
@@ -150,7 +150,7 @@ totext_ipseckey(ARGS_TOTEXT) {
*/
num
=
uint8_fromregion
(
&
region
);
isc_region_consume
(
&
region
,
1
);
sprintf
(
buf
,
"%u "
,
num
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u "
,
num
);
RETERR
(
str_totext
(
buf
,
target
));
/*
...
...
lib/dns/rdata/generic/key_25.c
View file @
a009d03a
...
...
@@ -85,7 +85,7 @@ generic_totext_key(ARGS_TOTEXT) {
/* flags */
flags
=
uint16_fromregion
(
&
sr
);
isc_region_consume
(
&
sr
,
2
);
sprintf
(
buf
,
"%u"
,
flags
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u"
,
flags
);
RETERR
(
str_totext
(
buf
,
target
));
RETERR
(
str_totext
(
" "
,
target
));
if
((
flags
&
DNS_KEYFLAG_KSK
)
!=
0
)
{
...
...
@@ -98,14 +98,14 @@ generic_totext_key(ARGS_TOTEXT) {
/* protocol */
sprintf
(
buf
,
"%u"
,
sr
.
base
[
0
]);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u"
,
sr
.
base
[
0
]);
isc_region_consume
(
&
sr
,
1
);
RETERR
(
str_totext
(
buf
,
target
));
RETERR
(
str_totext
(
" "
,
target
));
/* algorithm */
algorithm
=
sr
.
base
[
0
];
sprintf
(
buf
,
"%u"
,
algorithm
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%u"
,
algorithm
);
isc_region_consume
(
&
sr
,
1
);
RETERR
(
str_totext
(
buf
,
target
));
...
...
@@ -161,7 +161,8 @@ generic_totext_key(ARGS_TOTEXT) {
RETERR
(
str_totext
(
algbuf
,
target
));
RETERR
(
str_totext
(
" ; key id = "
,
target
));
dns_rdata_toregion
(
rdata
,
&
tmpr
);
sprintf
(
buf
,
"%u"
,
dst_region_computeid
(
&
tmpr
,
algorithm
));
snprintf
(
buf
,
sizeof
(
buf
),
"%u"
,
dst_region_computeid
(
&
tmpr
,
algorithm
));
RETERR
(
str_totext
(
buf
,
target
));
}
return
(
ISC_R_SUCCESS
);
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment