aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c34
-rw-r--r--src/vlibapi/api_types.h6
-rw-r--r--src/vpp/api/api.c9
3 files changed, 33 insertions, 16 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index f7e076764aa..4c43fcfaa20 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -1302,18 +1302,30 @@ static void vl_api_show_version_reply_t_handler
if (retval >= 0)
{
+ char *s;
char *p = (char *) &mp->program;
- errmsg (" program: %s\n",
- vl_api_from_api_string ((vl_api_string_t *) p));
- p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
- errmsg (" version: %s\n",
- vl_api_from_api_string ((vl_api_string_t *) p));
- p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
- errmsg (" build date: %s\n",
- vl_api_from_api_string ((vl_api_string_t *) p));
- p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
- errmsg ("build directory: %s\n",
- vl_api_from_api_string ((vl_api_string_t *) p));
+
+ s = vl_api_from_api_string_c ((vl_api_string_t *) p);
+ errmsg (" program: %s\n", s);
+ free (s);
+
+ p +=
+ vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
+ s = vl_api_from_api_string_c ((vl_api_string_t *) p);
+ errmsg (" version: %s\n", s);
+ free (s);
+
+ p +=
+ vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
+ s = vl_api_from_api_string_c ((vl_api_string_t *) p);
+ errmsg (" build date: %s\n", s);
+ free (s);
+
+ p +=
+ vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
+ s = vl_api_from_api_string_c ((vl_api_string_t *) p);
+ errmsg ("build directory: %s\n", s);
+ free (s);
}
vam->retval = retval;
vam->result_ready = 1;
diff --git a/src/vlibapi/api_types.h b/src/vlibapi/api_types.h
index ffcd24d12b2..8a86612f0fb 100644
--- a/src/vlibapi/api_types.h
+++ b/src/vlibapi/api_types.h
@@ -50,4 +50,10 @@ vl_api_string_len (vl_api_string_t * astr)
return clib_net_to_host_u32 (astr->length);
}
+static inline char *
+vl_api_from_api_string_c (vl_api_string_t *astr)
+{
+ return strndup((char *)astr->buf, clib_net_to_host_u32(astr->length));
+}
+
#endif
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index 8e2e4cd75a6..3fce77acfc8 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -251,11 +251,10 @@ vl_api_show_version_t_handler (vl_api_show_version_t * mp)
char *vpe_api_get_version (void);
char *vpe_api_get_build_date (void);
- u32 program_len = strnlen_s ("vpe", 32) + 1;
- u32 version_len = strnlen_s (vpe_api_get_version (), 32) + 1;
- u32 build_date_len = strnlen_s (vpe_api_get_build_date (), 32) + 1;
- u32 build_directory_len =
- strnlen_s (vpe_api_get_build_directory (), 256) + 1;
+ u32 program_len = strnlen_s ("vpe", 32);
+ u32 version_len = strnlen_s (vpe_api_get_version (), 32);
+ u32 build_date_len = strnlen_s (vpe_api_get_build_date (), 32);
+ u32 build_directory_len = strnlen_s (vpe_api_get_build_directory (), 256);
u32 n = program_len + version_len + build_date_len + build_directory_len;