diff options
author | Steven <sluong@cisco.com> | 2017-09-07 09:20:56 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2017-09-08 12:46:10 +0000 |
commit | d6042d4f1ea0baf02bc87c72960a331a9e08dfab (patch) | |
tree | f0480a1ef95accb785a491c3b88505800932822f /src/plugins/memif/memif.c | |
parent | 932f74196d9571fd007cef32c234bd00ab75975e (diff) |
memif: fix coverity warnings as of 9/7
1. coverity complains about "buffer not null terminated" for strncpy because we
pass the size of the destination to the call which is equal to the true size
of the destination. We subtract 1 for the size to accommodate the null like all
other places are already doing it.
2. Add a check to tx_queues in memif_interface_tx_inline to avoid "divide by zero".
3. To avoid null pointer dereference in memif_create_if, change the goto done
rather than goto error and spit a more meaningful error rather than silent about it.
4. Shuffle a line to avoid "check after use" in vl_api_memif_delete_t_handler.
Change-Id: Icba7ecd5362c012a48ac35795d31aab356617420
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/plugins/memif/memif.c')
-rw-r--r-- | src/plugins/memif/memif.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c index af81faf2711..7e2d947f426 100644 --- a/src/plugins/memif/memif.c +++ b/src/plugins/memif/memif.c @@ -611,8 +611,11 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args) } else { - ret = VNET_API_ERROR_SYSCALL_ERROR_3; - goto error; + error = clib_error_return (0, "File exists for %s", + socket_filename); + clib_error_report (error); + rv = VNET_API_ERROR_VALUE_EXIST; + goto done; } } pool_get (mm->socket_files, msf); |