aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorlurchi <lurchi@strangeplace.net>2019-06-27 10:49:40 +0200
committerlurchi <lurchi@strangeplace.net>2019-06-27 10:49:40 +0200
commitb9771c5f5edcbeb965fa291a281943d866c3ddb6 (patch)
treee53141e844dfe7032d018cb5bfebd31fe02f7816 /src/testbed
parent0e7c93c3a0a3aa966503a8ae4caf3a21914e4126 (diff)
downloadgnunet-b9771c5f5edcbeb965fa291a281943d866c3ddb6.tar.gz
gnunet-b9771c5f5edcbeb965fa291a281943d866c3ddb6.zip
use GNUNET_strlcpy instead of strncpy where possible
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-helper-testbed.c1
-rw-r--r--src/testbed/gnunet-service-testbed.c2
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c6
-rw-r--r--src/testbed/testbed_api.c1
-rw-r--r--src/testbed/testbed_api_hosts.c6
5 files changed, 13 insertions, 3 deletions
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c
index 25d9724fa..c56a795a6 100644
--- a/src/testbed/gnunet-helper-testbed.c
+++ b/src/testbed/gnunet-helper-testbed.c
@@ -374,6 +374,7 @@ tokenizer_cb (void *cls,
374 if (0 != hostname_size) 374 if (0 != hostname_size)
375 { 375 {
376 hostname = GNUNET_malloc (hostname_size + 1); 376 hostname = GNUNET_malloc (hostname_size + 1);
377 /* intentionally use strncpy (hostname not null terminated) */
377 (void) strncpy (hostname, ((char *) &msg[1]) + trusted_ip_size + 1, 378 (void) strncpy (hostname, ((char *) &msg[1]) + trusted_ip_size + 1,
378 hostname_size); 379 hostname_size);
379 hostname[hostname_size] = '\0'; 380 hostname[hostname_size] = '\0';
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 51460f65b..d740d31bc 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -541,10 +541,12 @@ handle_add_host (void *cls,
541 if (0 != username_length) 541 if (0 != username_length)
542 { 542 {
543 username = GNUNET_malloc (username_length + 1); 543 username = GNUNET_malloc (username_length + 1);
544 /* intentionally use strncpy (message payload is not null terminated) */
544 strncpy (username, ptr, username_length); 545 strncpy (username, ptr, username_length);
545 ptr += username_length; 546 ptr += username_length;
546 } 547 }
547 hostname = GNUNET_malloc (hostname_length + 1); 548 hostname = GNUNET_malloc (hostname_length + 1);
549 /* intentionally use strncpy (message payload is not null terminated) */
548 strncpy (hostname, 550 strncpy (hostname,
549 ptr, 551 ptr,
550 hostname_length); 552 hostname_length);
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index 98a4282df..4d6a4d446 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -1908,9 +1908,9 @@ handle_remote_overlay_connect (void *cls,
1908 rocc->a_id = msg->peer_identity; 1908 rocc->a_id = msg->peer_identity;
1909 GNUNET_TESTING_peer_get_identity (peer->details.local.peer, 1909 GNUNET_TESTING_peer_get_identity (peer->details.local.peer,
1910 &pid); 1910 &pid);
1911 (void) strncpy (pid_str, 1911 (void) GNUNET_strlcpy (pid_str,
1912 GNUNET_i2s (&pid), 1912 GNUNET_i2s (&pid),
1913 15); 1913 sizeof (pid_str));
1914 LOG_DEBUG ("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n", 1914 LOG_DEBUG ("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1915 rocc->op_id, 1915 rocc->op_id,
1916 pid_str, 1916 pid_str,
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 793ed4edd..22ce7eb72 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -2014,6 +2014,7 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip,
2014 msg->config_size = htons (config_size); 2014 msg->config_size = htons (config_size);
2015 (void) strcpy ((char *) &msg[1], trusted_ip); 2015 (void) strcpy ((char *) &msg[1], trusted_ip);
2016 if (0 != hostname_len) 2016 if (0 != hostname_len)
2017 /* intentionally use strncpy (no null byte needed) */
2017 (void) strncpy (((char *) &msg[1]) + trusted_ip_len + 1, hostname, 2018 (void) strncpy (((char *) &msg[1]) + trusted_ip_len + 1, hostname,
2018 hostname_len); 2019 hostname_len);
2019 return msg; 2020 return msg;
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 327f84f2a..d6521f766 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -462,6 +462,9 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
462 { 462 {
463 size = pmatch[2].rm_eo - pmatch[2].rm_so; 463 size = pmatch[2].rm_eo - pmatch[2].rm_so;
464 username = GNUNET_malloc (size + 1); 464 username = GNUNET_malloc (size + 1);
465 /*
466 * Intentionally use strncpy (buf is not necessarily null-terminated)
467 */
465 username[size] = '\0'; 468 username[size] = '\0';
466 GNUNET_assert (NULL != strncpy (username, buf + pmatch[2].rm_so, size)); 469 GNUNET_assert (NULL != strncpy (username, buf + pmatch[2].rm_so, size));
467 } 470 }
@@ -471,6 +474,9 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
471 } 474 }
472 size = pmatch[3].rm_eo - pmatch[3].rm_so; 475 size = pmatch[3].rm_eo - pmatch[3].rm_so;
473 hostname = GNUNET_malloc (size + 1); 476 hostname = GNUNET_malloc (size + 1);
477 /*
478 * Intentionally use strncpy (buf is not necessarily null-terminated)
479 */
474 hostname[size] = '\0'; 480 hostname[size] = '\0';
475 GNUNET_assert (NULL != strncpy (hostname, buf + pmatch[3].rm_so, size)); 481 GNUNET_assert (NULL != strncpy (hostname, buf + pmatch[3].rm_so, size));
476 LOG (GNUNET_ERROR_TYPE_DEBUG, 482 LOG (GNUNET_ERROR_TYPE_DEBUG,