summaryrefslogtreecommitdiffstats
path: root/vlib-api
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-07-26 10:30:50 -0400
committerDave Barach <dave@barachs.net>2016-07-26 10:31:05 -0400
commitac0798db359eb0de2eae1a54b63dfaa9534984c8 (patch)
tree6ee4810cbed91cb517629f5132a9872882439e4d /vlib-api
parent0f1c29c9d45edcc2d226a8e519db3e56888e3181 (diff)
Fix coverity warnings
Change-Id: I37131f2d814a608fe9098daff83ff395f7ce99d7 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vlib-api')
-rw-r--r--vlib-api/vlibapi/api_shared.c2
-rw-r--r--vlib-api/vlibmemory/memory_vlib.c7
-rw-r--r--vlib-api/vlibsocket/sockclnt_vlib.c1
-rw-r--r--vlib-api/vlibsocket/socksvr_vlib.c1
4 files changed, 10 insertions, 1 deletions
diff --git a/vlib-api/vlibapi/api_shared.c b/vlib-api/vlibapi/api_shared.c
index 18b189e1837..66f894b4edf 100644
--- a/vlib-api/vlibapi/api_shared.c
+++ b/vlib-api/vlibapi/api_shared.c
@@ -780,6 +780,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
if (!(statb.st_mode & S_IFREG) || (statb.st_size < sizeof (*hp)))
{
vlib_cli_output (vm, "File not plausible: %s\n", filename);
+ close(fd);
return;
}
@@ -814,6 +815,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
{
vlib_cli_output (vm, "Range (%d, %d) outside file range (0, %d)\n",
first_index, last_index, nitems - 1);
+ munmap (hp, file_size);
return;
}
if (hp->wrapped)
diff --git a/vlib-api/vlibmemory/memory_vlib.c b/vlib-api/vlibmemory/memory_vlib.c
index c2c14acf183..13b1121a0f4 100644
--- a/vlib-api/vlibmemory/memory_vlib.c
+++ b/vlib-api/vlibmemory/memory_vlib.c
@@ -1042,7 +1042,12 @@ vl_api_trace_print_file_cmd (vlib_main_t * vm, u32 first, u32 last,
}
msg_id = ntohs (msg_id);
- fseek (fp, -2, SEEK_CUR);
+ if (fseek (fp, -2, SEEK_CUR) < 0)
+ {
+ vlib_cli_output (vm, "fseek failed, %s", strerror(errno));
+ fclose(fp);
+ return;
+ }
/* Mild sanity check */
if (msg_id >= vec_len (am->msg_handlers))
diff --git a/vlib-api/vlibsocket/sockclnt_vlib.c b/vlib-api/vlibsocket/sockclnt_vlib.c
index d173c860ea2..4ae274c228e 100644
--- a/vlib-api/vlibsocket/sockclnt_vlib.c
+++ b/vlib-api/vlibsocket/sockclnt_vlib.c
@@ -114,6 +114,7 @@ sockclnt_open_index (char *client_name, char *hostname, int port)
if (rv < 0)
{
clib_unix_warning ("FIONBIO");
+ close(sockfd);
return ~0;
}
diff --git a/vlib-api/vlibsocket/socksvr_vlib.c b/vlib-api/vlibsocket/socksvr_vlib.c
index e70124d3a57..91c6bfde674 100644
--- a/vlib-api/vlibsocket/socksvr_vlib.c
+++ b/vlib-api/vlibsocket/socksvr_vlib.c
@@ -608,6 +608,7 @@ socksvr_api_init (vlib_main_t * vm)
rv = listen (sockfd, 5);
if (rv < 0)
{
+ close(sockfd);
return clib_error_return_unix (0, "listen");
}