summaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps/vcl
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-04-04 18:34:41 -0400
committerDave Barach <dave@barachs.net>2020-04-04 18:37:01 -0400
commit0250090fc0c24214cb1fa969f6e2f585099ee36b (patch)
tree7fd794527aea622f109613d168fc8fc418589eb0 /src/plugins/hs_apps/vcl
parent9f86d225ab4f3dccbf61383a75d6af7d321a204e (diff)
misc: strcpy be gone
Causes static analysis "vulnerability" warnings Type: fix Ticket: VPP-1837 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I272fa69251d70f62178e6dff0423c16f99937af1
Diffstat (limited to 'src/plugins/hs_apps/vcl')
-rw-r--r--src/plugins/hs_apps/vcl/sock_test_client.c7
-rw-r--r--src/plugins/hs_apps/vcl/sock_test_server.c3
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test_client.c2
3 files changed, 7 insertions, 5 deletions
diff --git a/src/plugins/hs_apps/vcl/sock_test_client.c b/src/plugins/hs_apps/vcl/sock_test_client.c
index 6f5fb074503..fb59378e008 100644
--- a/src/plugins/hs_apps/vcl/sock_test_client.c
+++ b/src/plugins/hs_apps/vcl/sock_test_client.c
@@ -252,7 +252,8 @@ echo_test_client ()
}
memset (&serveraddr, 0, sizeof (serveraddr));
serveraddr.sun_family = AF_UNIX;
- strcpy (serveraddr.sun_path, SOCK_TEST_AF_UNIX_FILENAME);
+ strncpy (serveraddr.sun_path, SOCK_TEST_AF_UNIX_FILENAME,
+ sizeof (serveraddr.sun_path));
rv = connect (fd, (struct sockaddr *) &serveraddr, SUN_LEN (&serveraddr));
if (rv < 0)
{
@@ -265,7 +266,7 @@ echo_test_client ()
}
scm->af_unix_echo_tx++;
- strcpy ((char *) buffer, SOCK_TEST_MIXED_EPOLL_DATA);
+ strncpy ((char *) buffer, SOCK_TEST_MIXED_EPOLL_DATA, sizeof (buffer));
timeout.tv_sec = 0;
timeout.tv_usec = 250000;
select (0, NULL, NULL, NULL, &timeout); /* delay .25 secs */
@@ -946,7 +947,7 @@ main (int argc, char **argv)
optopt, ctrl->txbuf_size);
print_usage_and_exit ();
}
- strcpy (ctrl->txbuf, optarg);
+ strncpy (ctrl->txbuf, optarg, ctrl->txbuf_size);
ctrl->cfg.test = VCL_TEST_TYPE_ECHO;
break;
diff --git a/src/plugins/hs_apps/vcl/sock_test_server.c b/src/plugins/hs_apps/vcl/sock_test_server.c
index bd777ccb917..801cd83cc83 100644
--- a/src/plugins/hs_apps/vcl/sock_test_server.c
+++ b/src/plugins/hs_apps/vcl/sock_test_server.c
@@ -559,7 +559,8 @@ main (int argc, char **argv)
memset (&ssm->serveraddr, 0, sizeof (ssm->serveraddr));
ssm->serveraddr.sun_family = AF_UNIX;
- strcpy (ssm->serveraddr.sun_path, SOCK_TEST_AF_UNIX_FILENAME);
+ strncpy (ssm->serveraddr.sun_path, SOCK_TEST_AF_UNIX_FILENAME,
+ sizeof (ssm->serveraddr.sun_path));
rv = bind (ssm->af_unix_listen_fd, (struct sockaddr *) &ssm->serveraddr,
SUN_LEN (&ssm->serveraddr));
diff --git a/src/plugins/hs_apps/vcl/vcl_test_client.c b/src/plugins/hs_apps/vcl/vcl_test_client.c
index 30b48d8d145..236cbfff913 100644
--- a/src/plugins/hs_apps/vcl/vcl_test_client.c
+++ b/src/plugins/hs_apps/vcl/vcl_test_client.c
@@ -912,7 +912,7 @@ vtc_process_opts (vcl_test_client_main_t * vcm, int argc, char **argv)
optopt, ctrl->txbuf_size);
print_usage_and_exit ();
}
- strcpy (ctrl->txbuf, optarg);
+ strncpy (ctrl->txbuf, optarg, ctrl->txbuf_size);
ctrl->cfg.test = VCL_TEST_TYPE_ECHO;
break;