diff options
Diffstat (limited to 'usr.sbin/bind/bin/tests')
-rw-r--r-- | usr.sbin/bind/bin/tests/db_test.c | 4 | ||||
-rw-r--r-- | usr.sbin/bind/bin/tests/dst/t_dst.c | 6 | ||||
-rw-r--r-- | usr.sbin/bind/bin/tests/hash_test.c | 14 | ||||
-rw-r--r-- | usr.sbin/bind/bin/tests/nxtify.c | 2 | ||||
-rw-r--r-- | usr.sbin/bind/bin/tests/rwlock_test.c | 2 | ||||
-rw-r--r-- | usr.sbin/bind/bin/tests/shutdown_test.c | 4 | ||||
-rw-r--r-- | usr.sbin/bind/bin/tests/sock_test.c | 22 |
7 files changed, 29 insertions, 25 deletions
diff --git a/usr.sbin/bind/bin/tests/db_test.c b/usr.sbin/bind/bin/tests/db_test.c index d3717ebc438..28c32f1f5a4 100644 --- a/usr.sbin/bind/bin/tests/db_test.c +++ b/usr.sbin/bind/bin/tests/db_test.c @@ -387,7 +387,7 @@ main(int argc, char *argv[]) { - strcpy(dbtype, "rbt"); + strlcpy(dbtype, "rbt", sizeof(dbtype)); while ((ch = isc_commandline_parse(argc, argv, "c:d:t:z:P:Q:glpqvT")) != -1) { switch (ch) { @@ -399,7 +399,7 @@ main(int argc, char *argv[]) { isc_result_totext(result)); break; case 'd': - strcpy(dbtype, isc_commandline_argument); + strlcpy(dbtype, isc_commandline_argument, sizeof(dbtype)); break; case 'g': options |= (DNS_DBFIND_GLUEOK|DNS_DBFIND_VALIDATEGLUE); diff --git a/usr.sbin/bind/bin/tests/dst/t_dst.c b/usr.sbin/bind/bin/tests/dst/t_dst.c index eba3374d118..9758cab8037 100644 --- a/usr.sbin/bind/bin/tests/dst/t_dst.c +++ b/usr.sbin/bind/bin/tests/dst/t_dst.c @@ -73,9 +73,9 @@ cleandir(char *path) { continue; if (! strcmp(pe->d_name, "..")) continue; - strcpy(fullname, path); - strcat(fullname, "/"); - strcat(fullname, pe->d_name); + strlcpy(fullname, path, sizeof(fullname)); + strlcat(fullname, "/", sizeof(fullname)); + strlcat(fullname, pe->d_name, sizeof(fullname)); if (remove(fullname)) t_info("remove(%s) failed %d\n", fullname, errno); diff --git a/usr.sbin/bind/bin/tests/hash_test.c b/usr.sbin/bind/bin/tests/hash_test.c index 8d27619c120..b8fb37daf56 100644 --- a/usr.sbin/bind/bin/tests/hash_test.c +++ b/usr.sbin/bind/bin/tests/hash_test.c @@ -58,21 +58,21 @@ main(int argc, char **argv) { s = "abc"; isc_sha1_init(&sha1); - strcpy(buffer, s); + strlcpy(buffer, s, sizeof(buffer)); isc_sha1_update(&sha1, buffer, strlen(s)); isc_sha1_final(&sha1, digest); print_digest(buffer, "sha1", digest, 5); s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; isc_sha1_init(&sha1); - strcpy(buffer, s); + strlcpy(buffer, s, sizeof(buffer)); isc_sha1_update(&sha1, buffer, strlen(s)); isc_sha1_final(&sha1, digest); print_digest(buffer, "sha1", digest, 5); s = "abc"; isc_md5_init(&md5); - strcpy(buffer, s); + strlcpy(buffer, s, sizeof(buffer)); isc_md5_update(&md5, buffer, strlen(s)); isc_md5_final(&md5, digest); print_digest(buffer, "md5", digest, 4); @@ -83,15 +83,15 @@ main(int argc, char **argv) { s = "Hi There"; memset(key, 0x0b, 16); isc_hmacmd5_init(&hmacmd5, key, 16); - strcpy(buffer, s); + strlcpy(buffer, s, sizeof(buffer)); isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); isc_hmacmd5_sign(&hmacmd5, digest); print_digest(buffer, "hmacmd5", digest, 4); s = "what do ya want for nothing?"; - strcpy(key, "Jefe"); + strlcpy(key, "Jefe", sizeof(key)); isc_hmacmd5_init(&hmacmd5, key, 4); - strcpy(buffer, s); + strlcpy(buffer, s, sizeof(buffer)); isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); isc_hmacmd5_sign(&hmacmd5, digest); print_digest(buffer, "hmacmd5", digest, 4); @@ -103,7 +103,7 @@ main(int argc, char **argv) { "\335\335\335\335\335\335\335\335\335\335"; memset(key, 0xaa, 16); isc_hmacmd5_init(&hmacmd5, key, 16); - strcpy(buffer, s); + strlcpy(buffer, s, sizeof(buffer)); isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); isc_hmacmd5_sign(&hmacmd5, digest); print_digest(buffer, "hmacmd5", digest, 4); diff --git a/usr.sbin/bind/bin/tests/nxtify.c b/usr.sbin/bind/bin/tests/nxtify.c index c5c8ef8cc80..2a0d9c4ee7f 100644 --- a/usr.sbin/bind/bin/tests/nxtify.c +++ b/usr.sbin/bind/bin/tests/nxtify.c @@ -186,7 +186,7 @@ nxtify(char *filename) { len = strlen(filename); if (len + 4 + 1 > sizeof newfilename) fatal("filename too long"); - sprintf(newfilename, "%s.new", filename); + snprintf(newfilename, sizeof(newfilename), "%s.new", filename); result = dns_db_dump(db, NULL, newfilename); check_result(result, "dns_db_dump"); dns_db_detach(&db); diff --git a/usr.sbin/bind/bin/tests/rwlock_test.c b/usr.sbin/bind/bin/tests/rwlock_test.c index cc6629a87ff..ff24875f7cb 100644 --- a/usr.sbin/bind/bin/tests/rwlock_test.c +++ b/usr.sbin/bind/bin/tests/rwlock_test.c @@ -107,7 +107,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); + snprintf(name, sizeof(name), "%02u", i); dupname = strdup(name); RUNTIME_CHECK(dupname != NULL); if (i != 0 && i % 3 == 0) diff --git a/usr.sbin/bind/bin/tests/shutdown_test.c b/usr.sbin/bind/bin/tests/shutdown_test.c index 6ad2347105e..4fc5c61c1fa 100644 --- a/usr.sbin/bind/bin/tests/shutdown_test.c +++ b/usr.sbin/bind/bin/tests/shutdown_test.c @@ -145,9 +145,9 @@ new_task(isc_mem_t *mctx, const char *name) { ti->ticks = 0; if (name != NULL) { INSIST(strlen(name) < sizeof(ti->name)); - strcpy(ti->name, name); + strlcpy(ti->name, name, sizeof(ti->name)); } else - sprintf(ti->name, "%d", task_count); + snprintf(ti->name, sizeof(ti->name), "%d", task_count); RUNTIME_CHECK(isc_task_create(task_manager, 0, &ti->task) == ISC_R_SUCCESS); RUNTIME_CHECK(isc_task_onshutdown(ti->task, shutdown_action, ti) == diff --git a/usr.sbin/bind/bin/tests/sock_test.c b/usr.sbin/bind/bin/tests/sock_test.c index 8bf9baaf0d1..df8f9f31d42 100644 --- a/usr.sbin/bind/bin/tests/sock_test.c +++ b/usr.sbin/bind/bin/tests/sock_test.c @@ -107,12 +107,14 @@ my_recv(isc_task_t *task, isc_event_t *event) { * Echo the data back. */ if (strcmp(event->ev_arg, "so2") != 0) { + size_t len; region = dev->region; - sprintf(buf, "\r\nReceived: %.*s\r\n\r\n", + snprintf(buf, sizeof(buf), "\r\nReceived: %.*s\r\n\r\n", (int)dev->n, (char *)region.base); - region.base = isc_mem_get(mctx, strlen(buf) + 1); - region.length = strlen(buf) + 1; - strcpy((char *)region.base, buf); /* strcpy is safe */ + len = strlen(buf) + 1; + region.base = isc_mem_get(mctx, len); + region.length = len; + strlcpy((char *)region.base, buf, len); isc_socket_send(sock, ®ion, task, my_send, event->ev_arg); } else { region = dev->region; @@ -157,6 +159,7 @@ my_connect(isc_task_t *task, isc_event_t *event) { isc_socket_connev_t *dev; isc_region_t region; char buf[1024]; + size_t len; sock = event->ev_sender; dev = (isc_socket_connev_t *)event; @@ -175,11 +178,12 @@ my_connect(isc_task_t *task, isc_event_t *event) { * Send a GET string, and set up to receive (and just display) * the result. */ - strcpy(buf, "GET / HTTP/1.1\r\nHost: www.flame.org\r\n" - "Connection: Close\r\n\r\n"); - region.base = isc_mem_get(mctx, strlen(buf) + 1); - region.length = strlen(buf) + 1; - strcpy((char *)region.base, buf); /* This strcpy is safe. */ + strlcpy(buf, "GET / HTTP/1.1\r\nHost: www.flame.org\r\n" + "Connection: Close\r\n\r\n", sizeof(buf)); + len = strlen(buf) + 1; + region.base = isc_mem_get(mctx, len); + region.length = len; + strlcpy((char *)region.base, buf, len); isc_socket_send(sock, ®ion, task, my_http_get, event->ev_arg); |