From 7504e99a8b4ad1bff9bf64ba16fe00fa708e5b1a Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Tue, 10 Oct 2017 08:43:35 +0200 Subject: API versioning: Fix coverity errors from strncpy() Change-Id: Ife87f9b00f918ff1bb8c91c6f13ebe53a3555a12 Signed-off-by: Ole Troan --- src/vlibapi/api_shared.c | 2 +- src/vlibmemory/memory_vlib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c index 831e863393b..1bb50d43def 100644 --- a/src/vlibapi/api_shared.c +++ b/src/vlibapi/api_shared.c @@ -921,7 +921,7 @@ vl_msg_api_add_version (api_main_t * am, const char *string, { api_version_t version = {.major = major,.minor = minor,.patch = patch }; ASSERT (strlen (string) < 64); - strncpy (version.name, string, 64); + strncpy (version.name, string, 64 - 1); vec_add1 (am->api_version_list, version); } diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c index c3aef65e854..65d04dc266f 100644 --- a/src/vlibmemory/memory_vlib.c +++ b/src/vlibmemory/memory_vlib.c @@ -498,7 +498,7 @@ vl_api_api_versions_t_handler (vl_api_api_versions_t * mp) rmp->api_versions[i].major = htonl (vl->major); rmp->api_versions[i].minor = htonl (vl->minor); rmp->api_versions[i].patch = htonl (vl->patch); - strncpy ((char *) rmp->api_versions[i].name, vl->name, 64); + strncpy ((char *) rmp->api_versions[i].name, vl->name, 64 - 1); } vl_msg_api_send_shmem (q, (u8 *) & rmp); -- cgit 1.2.3-korg