summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vlib-api/vlibapi/api_shared.c1
-rw-r--r--vlib-api/vlibsocket/sockclnt_vlib.c1
-rw-r--r--vlib-api/vlibsocket/socksvr_vlib.c1
-rw-r--r--vlib/vlib/node.c7
-rw-r--r--vlib/vlib/threads.c10
-rw-r--r--vlib/vlib/threads_cli.c4
-rw-r--r--vlib/vlib/unix/cli.c10
-rw-r--r--vlib/vlib/unix/main.c5
-rw-r--r--vlib/vlib/unix/mc_socket.c5
-rw-r--r--vlib/vlib/unix/util.c8
-rw-r--r--vnet/vnet/cdp/cdp_input.c2
11 files changed, 39 insertions, 15 deletions
diff --git a/vlib-api/vlibapi/api_shared.c b/vlib-api/vlibapi/api_shared.c
index 66f894b4edf..09502c692c3 100644
--- a/vlib-api/vlibapi/api_shared.c
+++ b/vlib-api/vlibapi/api_shared.c
@@ -774,6 +774,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
if (fstat (fd, &statb) < 0)
{
vlib_cli_output (vm, "Couldn't stat %s\n", filename);
+ close (fd);
return;
}
diff --git a/vlib-api/vlibsocket/sockclnt_vlib.c b/vlib-api/vlibsocket/sockclnt_vlib.c
index 4ae274c228e..e8d749c58d4 100644
--- a/vlib-api/vlibsocket/sockclnt_vlib.c
+++ b/vlib-api/vlibsocket/sockclnt_vlib.c
@@ -107,6 +107,7 @@ sockclnt_open_index (char *client_name, char *hostname, int port)
if (connect (sockfd, (const void *) &serv_addr, sizeof (serv_addr)) < 0)
{
clib_unix_warning ("Connect failure to (%s, %d)", hostname, port);
+ close(sockfd);
return ~0;
}
diff --git a/vlib-api/vlibsocket/socksvr_vlib.c b/vlib-api/vlibsocket/socksvr_vlib.c
index 91c6bfde674..eb8dd3340a1 100644
--- a/vlib-api/vlibsocket/socksvr_vlib.c
+++ b/vlib-api/vlibsocket/socksvr_vlib.c
@@ -602,6 +602,7 @@ socksvr_api_init (vlib_main_t * vm)
if (bind (sockfd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0)
{
+ close (sockfd);
return clib_error_return_unix (0, "bind");
}
diff --git a/vlib/vlib/node.c b/vlib/vlib/node.c
index 838f34199bd..3d26559a03d 100644
--- a/vlib/vlib/node.c
+++ b/vlib/vlib/node.c
@@ -486,8 +486,11 @@ vlib_node_main_init (vlib_main_t * vm)
sib = vlib_get_node_by_name (vm, (u8 *) n->sibling_of);
if (!sib)
- clib_error ("sibling `%s' not found for node `%v'", n->sibling_of,
- n->name);
+ {
+ error = clib_error_create ("sibling `%s' not found for node `%v'",
+ n->sibling_of, n->name);
+ goto done;
+ }
/* *INDENT-OFF* */
clib_bitmap_foreach (si, sib->sibling_bitmap, ({
diff --git a/vlib/vlib/threads.c b/vlib/vlib/threads.c
index 47db218dc0e..72f340ea205 100644
--- a/vlib/vlib/threads.c
+++ b/vlib/vlib/threads.c
@@ -81,10 +81,15 @@ void
vlib_set_thread_name (char *name)
{
int pthread_setname_np (pthread_t __target_thread, const char *__name);
+ int rv;
pthread_t thread = pthread_self ();
if (thread)
- pthread_setname_np (thread, name);
+ {
+ rv = pthread_setname_np (thread, name);
+ if (rv)
+ clib_warning ("pthread_setname_np returned %d", rv);
+ }
}
static int
@@ -114,7 +119,8 @@ vlib_sysfs_list_to_bitmap (char *filename)
unformat_input_t in;
unformat_init_string (&in, (char *) buffer,
strlen ((char *) buffer));
- unformat (&in, "%U", unformat_bitmap_list, &r);
+ if (unformat (&in, "%U", unformat_bitmap_list, &r) != 1)
+ clib_warning ("unformat_bitmap_list failed");
unformat_free (&in);
}
vec_free (buffer);
diff --git a/vlib/vlib/threads_cli.c b/vlib/vlib/threads_cli.c
index 919baac5640..9ab4edcd357 100644
--- a/vlib/vlib/threads_cli.c
+++ b/vlib/vlib/threads_cli.c
@@ -321,8 +321,8 @@ test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input,
u32 fqix;
u32 nelts = 0;
- unformat (input, "%d", &nelts);
- if ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32))
+ if ((unformat (input, "%d", &nelts) != 1) ||
+ ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32)))
{
return clib_error_return (0, "expecting 4,8,16,32");
}
diff --git a/vlib/vlib/unix/cli.c b/vlib/vlib/unix/cli.c
index e36b80ad990..7d5e10b8b8e 100644
--- a/vlib/vlib/unix/cli.c
+++ b/vlib/vlib/unix/cli.c
@@ -2345,7 +2345,13 @@ unix_cli_resize_interrupt (int signum)
(void) signum;
/* Terminal resized, fetch the new size */
- ioctl (UNIX_CLI_STDIN_FD, TIOCGWINSZ, &ws);
+ if (ioctl (UNIX_CLI_STDIN_FD, TIOCGWINSZ, &ws) < 0)
+ {
+ /* "Should never happen..." */
+ clib_unix_warning ("TIOCGWINSZ");
+ /* We can't trust ws.XXX... */
+ return;
+ }
cf->width = ws.ws_col;
cf->height = ws.ws_row;
@@ -2380,7 +2386,7 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input)
/* Set stdin to be non-blocking. */
if ((flags = fcntl (UNIX_CLI_STDIN_FD, F_GETFL, 0)) < 0)
flags = 0;
- fcntl (UNIX_CLI_STDIN_FD, F_SETFL, flags | O_NONBLOCK);
+ (void) fcntl (UNIX_CLI_STDIN_FD, F_SETFL, flags | O_NONBLOCK);
cf_index = unix_cli_file_add (cm, "stdin", UNIX_CLI_STDIN_FD);
cf = pool_elt_at_index (cm->cli_file_pool, cf_index);
diff --git a/vlib/vlib/unix/main.c b/vlib/vlib/unix/main.c
index b8753f4df93..3c17031b884 100644
--- a/vlib/vlib/unix/main.c
+++ b/vlib/vlib/unix/main.c
@@ -89,6 +89,7 @@ unix_signal_handler (int signum, siginfo_t * si, ucontext_t * uc)
clib_longjmp (&unix_main.vlib_main->main_loop_exit,
VLIB_MAIN_LOOP_EXIT_CLI);
}
+ /* fall through */
case SIGQUIT:
case SIGINT:
case SIGILL:
@@ -344,7 +345,7 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
int fd;
fd = open ("/proc/self/coredump_filter", O_WRONLY);
- if (fd > 0)
+ if (fd >= 0)
{
if (write (fd, "0x6f\n", 5) != 5)
clib_unix_warning ("coredump filter write failed!");
@@ -468,7 +469,7 @@ vlib_unix_main (int argc, char *argv[])
/* allocate N x 1mb stacks, aligned e.g. to a 16mb boundary */
thread_stacks = clib_mem_alloc_aligned
- (tm->n_thread_stacks * VLIB_THREAD_STACK_SIZE,
+ ((uword) tm->n_thread_stacks * VLIB_THREAD_STACK_SIZE,
(VLIB_MAX_CPUS << VLIB_LOG2_THREAD_STACK_SIZE));
sm->vm_base = thread_stacks;
diff --git a/vlib/vlib/unix/mc_socket.c b/vlib/vlib/unix/mc_socket.c
index 2077fd7c519..2754b302875 100644
--- a/vlib/vlib/unix/mc_socket.c
+++ b/vlib/vlib/unix/mc_socket.c
@@ -955,7 +955,10 @@ find_interface_ip4_address (char *if_name, u32 * ip4_address, u32 * mtu)
clib_memcpy (ip4_address, &sa->sin_addr.s_addr, sizeof (ip4_address[0]));
if (ioctl (fd, SIOCGIFMTU, &ifr) < 0)
- return -1;
+ {
+ close (fd);
+ return -1;
+ }
if (mtu)
*mtu = ifr.ifr_mtu - ( /* IP4 header */ 20 + /* UDP header */ 8);
diff --git a/vlib/vlib/unix/util.c b/vlib/vlib/unix/util.c
index f4a2c810dfc..9118f5b5283 100644
--- a/vlib/vlib/unix/util.c
+++ b/vlib/vlib/unix/util.c
@@ -103,6 +103,7 @@ vlib_sysfs_write (char *file_name, char *fmt, ...)
{
u8 *s;
int fd;
+ clib_error_t * error = 0;
fd = open (file_name, O_WRONLY);
if (fd < 0)
@@ -114,11 +115,11 @@ vlib_sysfs_write (char *file_name, char *fmt, ...)
va_end (va);
if (write (fd, s, vec_len (s)) < 0)
- return clib_error_return_unix (0, "write `%s'", file_name);
+ error = clib_error_return_unix (0, "write `%s'", file_name);
vec_free (s);
close (fd);
- return 0;
+ return error;
}
clib_error_t *
@@ -181,7 +182,8 @@ vlib_sysfs_link_to_name (char *link)
return 0;
unformat_init_string (&in, p + 1, strlen (p + 1));
- unformat (&in, "%s", &s);
+ if (unformat (&in, "%s", &s) != 1)
+ clib_unix_warning ("no string?");
unformat_free (&in);
return s;
diff --git a/vnet/vnet/cdp/cdp_input.c b/vnet/vnet/cdp/cdp_input.c
index d2d2306e01e..f7d54344283 100644
--- a/vnet/vnet/cdp/cdp_input.c
+++ b/vnet/vnet/cdp/cdp_input.c
@@ -461,7 +461,7 @@ u8 * cdp_input_format_trace (u8 * s, va_list * args)
tlv = (cdp_tlv_t *)cur;
tlv->t = ntohs(tlv->t);
tlv->l = ntohs(tlv->l);
- if (tlv->t > ARRAY_LEN(tlv_handlers)) {
+ if (tlv->t >= ARRAY_LEN(tlv_handlers)) {
s = format (s, "BAD_TLV\n");
break;
}