diff options
author | Todd T. Fries <todd@cvs.openbsd.org> | 2003-06-27 19:08:24 +0000 |
---|---|---|
committer | Todd T. Fries <todd@cvs.openbsd.org> | 2003-06-27 19:08:24 +0000 |
commit | d86da5bd6abde93d50f7b724a52771877c8cabbc (patch) | |
tree | 898d808c8e5b8d3698e098bb3660051ff61e7964 /usr.sbin/bind/bin | |
parent | 6af2197a68b3a0e9ce04f275a4ad9cd3d800e13d (diff) |
string cleaning; "Put it in. If it breaks, tough" Theo.
work by me, useful feedback from krw, jakob, tedu, and tholo
Diffstat (limited to 'usr.sbin/bind/bin')
-rw-r--r-- | usr.sbin/bind/bin/dig/dig.c | 19 | ||||
-rw-r--r-- | usr.sbin/bind/bin/dig/dighost.c | 11 | ||||
-rw-r--r-- | usr.sbin/bind/bin/dig/host.c | 9 | ||||
-rw-r--r-- | usr.sbin/bind/bin/dig/nslookup.c | 3 | ||||
-rw-r--r-- | usr.sbin/bind/bin/named/interfacemgr.c | 3 |
5 files changed, 16 insertions, 29 deletions
diff --git a/usr.sbin/bind/bin/dig/dig.c b/usr.sbin/bind/bin/dig/dig.c index bcbb3ac99cd..71045bbff95 100644 --- a/usr.sbin/bind/bin/dig/dig.c +++ b/usr.sbin/bind/bin/dig/dig.c @@ -619,7 +619,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, char *cmd, *value, *ptr; 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; cmd=next_token(&ptr,"="); @@ -718,8 +718,7 @@ plus_option(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; default: goto invalid_option; @@ -960,8 +959,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': port = (in_port_t) parse_uint(value, "port number", MAXPORT); @@ -1014,18 +1012,16 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, if (ptr == NULL) { usage(); } - strncpy(keynametext, ptr, sizeof(keynametext)); - keynametext[sizeof(keynametext)-1]=0; + strlcpy(keynametext, ptr, sizeof(keynametext)); ptr = next_token(&value, ""); if (ptr == NULL) usage(); - strncpy(keysecret, ptr, sizeof(keysecret)); - keysecret[sizeof(keysecret)-1]=0; + strlcpy(keysecret, ptr, sizeof(keysecret)); return (value_from_next); case 'x': *lookup = clone_lookup(default_lookup, ISC_TRUE); if (get_reverse(textname, value, nibble) == ISC_R_SUCCESS) { - strncpy((*lookup)->textname, textname, + strlcpy((*lookup)->textname, textname, sizeof((*lookup)->textname)); debug("looking up %s", (*lookup)->textname); (*lookup)->trace_root = ISC_TF((*lookup)->trace || @@ -1254,9 +1250,8 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, printgreeting(argc, argv, lookup); firstarg = ISC_FALSE; } - strncpy(lookup->textname, rv[0], + strlcpy(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; diff --git a/usr.sbin/bind/bin/dig/dighost.c b/usr.sbin/bind/bin/dig/dighost.c index db7f0561fe7..67364c7d861 100644 --- a/usr.sbin/bind/bin/dig/dighost.c +++ b/usr.sbin/bind/bin/dig/dighost.c @@ -300,8 +300,7 @@ make_server(const char *servname) { if (srv == NULL) fatal("Memory allocation failure in %s:%d", __FILE__, __LINE__); - strncpy(srv->servername, servname, MXNAME); - srv->servername[MXNAME-1] = 0; + strlcpy(srv->servername, servname, MXNAME); ISC_LINK_INIT(srv, link); return (srv); } @@ -410,9 +409,8 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) { looknew = make_empty_lookup(); INSIST(looknew != NULL); - strncpy(looknew->textname, lookold->textname, MXNAME); - strncpy(looknew->cmdline, lookold->cmdline, MXNAME); - looknew->textname[MXNAME-1] = 0; + strlcpy(looknew->textname, lookold->textname, MXNAME); + strlcpy(looknew->cmdline, lookold->cmdline, MXNAME); looknew->rdtype = lookold->rdtype; looknew->qrdtype = lookold->qrdtype; looknew->rdclass = lookold->rdclass; @@ -562,8 +560,7 @@ make_searchlist_entry(char *domain) { if (search == NULL) fatal("Memory allocation failure in %s:%d", __FILE__, __LINE__); - strncpy(search->origin, domain, MXNAME); - search->origin[MXNAME-1] = 0; + strlcpy(search->origin, domain, MXNAME); ISC_LINK_INIT(search, link); return (search); } diff --git a/usr.sbin/bind/bin/dig/host.c b/usr.sbin/bind/bin/dig/host.c index c3a0c0bedf9..82435a1450f 100644 --- a/usr.sbin/bind/bin/dig/host.c +++ b/usr.sbin/bind/bin/dig/host.c @@ -644,8 +644,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { if (isc_commandline_index >= argc) { show_usage(); } - strncpy(hostname, argv[isc_commandline_index], sizeof(hostname)); - hostname[sizeof(hostname)-1]=0; + strlcpy(hostname, argv[isc_commandline_index], sizeof(hostname)); if (argc > isc_commandline_index + 1) { srv = make_server(argv[isc_commandline_index+1]); debug("server is %s", srv->servername); @@ -655,13 +654,11 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { lookup->pending = ISC_FALSE; if (get_reverse(store, hostname, lookup->nibble) == 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; } else { - strncpy(lookup->textname, hostname, sizeof(lookup->textname)); - lookup->textname[sizeof(lookup->textname)-1]=0; + strlcpy(lookup->textname, hostname, sizeof(lookup->textname)); } lookup->new_search = ISC_TRUE; ISC_LIST_APPEND(lookup_list, lookup, link); diff --git a/usr.sbin/bind/bin/dig/nslookup.c b/usr.sbin/bind/bin/dig/nslookup.c index 1126149d7ba..c4efb3f6819 100644 --- a/usr.sbin/bind/bin/dig/nslookup.c +++ b/usr.sbin/bind/bin/dig/nslookup.c @@ -518,8 +518,7 @@ testclass(char *typetext) { static void safecpy(char *dest, char *src, int size) { - strncpy(dest, src, size); - dest[size-1] = 0; + strlcpy(dest, src, size); } diff --git a/usr.sbin/bind/bin/named/interfacemgr.c b/usr.sbin/bind/bin/named/interfacemgr.c index 4ee7939cd8e..80b9342c96b 100644 --- a/usr.sbin/bind/bin/named/interfacemgr.c +++ b/usr.sbin/bind/bin/named/interfacemgr.c @@ -182,8 +182,7 @@ ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr, ifp->mgr = NULL; ifp->generation = mgr->generation; ifp->addr = *addr; - strncpy(ifp->name, name, sizeof(ifp->name)); - ifp->name[sizeof(ifp->name)-1] = '\0'; + strlcpy(ifp->name, name, sizeof(ifp->name)); ifp->clientmgr = NULL; result = isc_mutex_init(&ifp->lock); |