aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-09-09 12:00:00 +0200
committerFlorin Coras <florin.coras@gmail.com>2021-09-09 14:18:27 +0000
commit0bb670eb661890b92a1e87895e63f46fd78db903 (patch)
tree1f2aab47accb5620c0dd2bd67516002929fd2b1c
parentc4794570967e5f82862131015462cab382fa8848 (diff)
session: fix non-NULL terminated string
vlib_unix_recursive_mkdir () expects a NULL-terminated C-string. Type: fix Change-Id: I412b48443d0792307d611c466747c0aa5e423417 Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/vnet/session/session_api.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index e6aac953bce..371fcfc9271 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -1720,26 +1720,21 @@ appns_sapi_add_ns_socket (app_namespace_t * app_ns)
struct stat file_stat;
clib_error_t *err;
clib_socket_t *cs;
- u8 *dir = 0;
- int rv = 0;
-
- vec_add (dir, vlib_unix_get_runtime_dir (),
- strlen (vlib_unix_get_runtime_dir ()));
- vec_add (dir, (u8 *) subdir, strlen (subdir));
+ char dir[4096];
+ snprintf (dir, sizeof (dir), "%s%s", vlib_unix_get_runtime_dir (), subdir);
err = vlib_unix_recursive_mkdir ((char *) dir);
if (err)
{
clib_error_report (err);
- rv = -1;
- goto error;
+ return -1;
}
/* Use abstract sockets if a netns was provided */
if (app_ns->netns)
app_ns->sock_name = format (0, "@vpp/session/%v%c", app_ns->ns_id, 0);
else
- app_ns->sock_name = format (0, "%v%v%c", dir, app_ns->ns_id, 0);
+ app_ns->sock_name = format (0, "%s%v%c", dir, app_ns->ns_id, 0);
/*
* Create and initialize socket to listen on
@@ -1753,15 +1748,11 @@ appns_sapi_add_ns_socket (app_namespace_t * app_ns)
if ((err = clib_socket_init_netns (cs, app_ns->netns)))
{
clib_error_report (err);
- rv = -1;
- goto error;
+ return -1;
}
if (!app_ns->netns && stat ((char *) app_ns->sock_name, &file_stat) == -1)
- {
- rv = -1;
- goto error;
- }
+ return -1;
/*
* Start polling it
@@ -1779,9 +1770,7 @@ appns_sapi_add_ns_socket (app_namespace_t * app_ns)
handle->aah_file_index = clib_file_add (&file_main, &cf);
handle->aah_app_wrk_index = APP_INVALID_INDEX;
-error:
- vec_free (dir);
- return rv;
+ return 0;
}
static void