diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2010-01-17 20:45:00 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2010-01-17 20:45:00 +0000 |
commit | d4a6fa80535c3a5c61c9a1e2224abd24b9985a9f (patch) | |
tree | 401f3fc0733ce9621909a83e4ebd22394fe1b0f1 /usr.sbin | |
parent | 233f8a77d6f586d24e1bb0d0caa895631000c112 (diff) |
strcpy/strncat/sprintf --> strlcpy/strlcat/snprintf
ok jakob@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/nsd/axfr.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/dname.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/dns.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/nsd.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/region-allocator.c | 7 | ||||
-rw-r--r-- | usr.sbin/nsd/util.c | 2 |
6 files changed, 10 insertions, 7 deletions
diff --git a/usr.sbin/nsd/axfr.c b/usr.sbin/nsd/axfr.c index 0bec4877f97..ae17388575e 100644 --- a/usr.sbin/nsd/axfr.c +++ b/usr.sbin/nsd/axfr.c @@ -179,7 +179,7 @@ answer_axfr_ixfr(struct nsd *nsd, struct query *q) if (addr2ip(q->addr, address, 128)) { DEBUG(DEBUG_XFRD,1, (LOG_INFO, "addr2ip failed")); - strcpy(address, "[unknown]"); + strlcpy(address, "[unknown]", sizeof(address)); } VERBOSITY(1, (LOG_INFO, "axfr for zone %s from client %s refused, %s", dname_to_string(q->qname, NULL), address, acl?"blocked":"no acl matches")); diff --git a/usr.sbin/nsd/dname.c b/usr.sbin/nsd/dname.c index d264d202f7e..5640899c1a1 100644 --- a/usr.sbin/nsd/dname.c +++ b/usr.sbin/nsd/dname.c @@ -389,7 +389,7 @@ dname_to_string(const dname_type *dname, const dname_type *origin) const uint8_t *src; if (dname->label_count == 1) { - strcpy(buf, "."); + strlcpy(buf, ".", sizeof(buf)); return buf; } diff --git a/usr.sbin/nsd/dns.c b/usr.sbin/nsd/dns.c index 2299f66a8a6..ec227f9f5d9 100644 --- a/usr.sbin/nsd/dns.c +++ b/usr.sbin/nsd/dns.c @@ -522,7 +522,7 @@ rrclass_to_string(uint16_t rrclass) lookup_table_type *entry = lookup_by_id(dns_rrclasses, rrclass); if (entry) { assert(strlen(entry->name) < sizeof(buf)); - strcpy(buf, entry->name); + strlcpy(buf, entry->name, sizeof(buf)); } else { snprintf(buf, sizeof(buf), "CLASS%d", (int) rrclass); } diff --git a/usr.sbin/nsd/nsd.c b/usr.sbin/nsd/nsd.c index b223a1f28b8..8dac3bf0f79 100644 --- a/usr.sbin/nsd/nsd.c +++ b/usr.sbin/nsd/nsd.c @@ -822,7 +822,7 @@ main(int argc, char *argv[]) if (l>0 && strncmp(nsd.chrootdir + (l-1), "/", 1) != 0) { char *chroot_slash = region_alloc(nsd.region, sizeof(char)*(l+2)); memcpy(chroot_slash, nsd.chrootdir, sizeof(char)*(l+1)); - strncat(chroot_slash, "/", 1); + strlcat(chroot_slash, "/", sizeof(char)*(l+2)); nsd.chrootdir = chroot_slash; ++l; } diff --git a/usr.sbin/nsd/region-allocator.c b/usr.sbin/nsd/region-allocator.c index c2ad8215264..fd9ef537a4a 100644 --- a/usr.sbin/nsd/region-allocator.c +++ b/usr.sbin/nsd/region-allocator.c @@ -426,8 +426,9 @@ void region_log_stats(region_type *region) { char buf[10240], *str=buf; + int strl = sizeof(buf); int len=0; - sprintf(str, "%lu objects (%lu small/%lu large), %lu bytes allocated (%lu wasted) in %lu chunks, %lu cleanups, %lu in recyclebin%n", + snprintf(str, strl, "%lu objects (%lu small/%lu large), %lu bytes allocated (%lu wasted) in %lu chunks, %lu cleanups, %lu in recyclebin%n", (unsigned long) (region->small_objects + region->large_objects), (unsigned long) region->small_objects, (unsigned long) region->large_objects, @@ -438,6 +439,7 @@ region_log_stats(region_type *region) (unsigned long) region->recycle_size, &len); str+=len; + strl-=len; if(1 && region->recycle_bin) { /* print details of the recycle bin */ size_t i; @@ -449,9 +451,10 @@ region_log_stats(region_type *region) el = el->next; } if(i%ALIGNMENT == 0 && i!=0) { - sprintf(str, " %lu%n", (unsigned long)count, + snprintf(str, strl, " %lu%n", (unsigned long)count, &len); str+=len; + strl-=len; } } } diff --git a/usr.sbin/nsd/util.c b/usr.sbin/nsd/util.c index dbdf64308e7..e19a23a8ac1 100644 --- a/usr.sbin/nsd/util.c +++ b/usr.sbin/nsd/util.c @@ -534,7 +534,7 @@ b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) { if(targsize < strlen(buf)+1) return -1; - strcpy(target, buf); + strlcpy(target, buf, targsize); len += strlen(buf); } else if(targsize < 1) |