summaryrefslogtreecommitdiffstats
path: root/src/vlibapi
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-12-14 20:34:29 +0100
committerDave Barach <openvpp@barachs.net>2018-12-14 22:50:51 +0000
commit884f0aff0e94ee35d7dd3c6dd55041d4872a9a9b (patch)
treedf99d8ee8db09d41fb8998ff97b95758f131d13c /src/vlibapi
parentc5b6b3198069717f836807b57d01607c6711fb02 (diff)
String type: Fix off by one error
String is not sent nul terminated across API. The hardest two problems in computer science is cache invalidation naming and off by one errors. Change-Id: I36f1952ca955cb2d9dfb4c8120ec48c50ba17991 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vlibapi')
-rw-r--r--src/vlibapi/api_types.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/vlibapi/api_types.h b/src/vlibapi/api_types.h
index 759298e735d..ffcd24d12b2 100644
--- a/src/vlibapi/api_types.h
+++ b/src/vlibapi/api_types.h
@@ -32,13 +32,12 @@ typedef struct
static inline int
vl_api_to_api_string (u32 len, const char *buf, vl_api_string_t * str)
{
- if (strncpy_s ((char *) str->buf, len, buf, len - 1) != 0)
- len = 0;
+ clib_memcpy(str->buf, buf, len);
str->length = clib_host_to_net_u32 (len);
return len + sizeof (u32);
}
-/* Return a C string from API string */
+/* Return a pointer to the API string (not nul terminated */
static inline u8 *
vl_api_from_api_string (vl_api_string_t * astr)
{