aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri
diff options
context:
space:
mode:
authorChris Luke <chrisy@flirble.org>2017-09-07 07:40:13 -0400
committerDave Wallace <dwallacelf@gmail.com>2017-09-08 02:17:27 +0000
commitab7b8d93cf1098970bc17fb4937376bb1ff33a21 (patch)
treeb1c0c89e34cb87f6cd8c1f783654bf66c7b50ac9 /src/uri
parent8a19f12a0cfe6d611f6e266931af691fb69a74ad (diff)
Fixes for issues reported by Coverity (VPP-972)
Change-Id: I25238debb7081b4467aec4620dfdef33fbef3295 Signed-off-by: Chris Luke <chrisy@flirble.org>
Diffstat (limited to 'src/uri')
-rw-r--r--src/uri/sock_test_client.c2
-rw-r--r--src/uri/sock_test_server.c12
-rw-r--r--src/uri/vppcom.c17
3 files changed, 19 insertions, 12 deletions
diff --git a/src/uri/sock_test_client.c b/src/uri/sock_test_client.c
index 4319f01b5ab..ab8e5a0e4a7 100644
--- a/src/uri/sock_test_client.c
+++ b/src/uri/sock_test_client.c
@@ -895,6 +895,8 @@ main (int argc, char **argv)
case 'w':
fprintf (stderr, "ERROR: Option -%c requires an argument.\n",
optopt);
+ break;
+
default:
if (isprint (optopt))
fprintf (stderr, "ERROR: Unknown option `-%c'.\n", optopt);
diff --git a/src/uri/sock_test_server.c b/src/uri/sock_test_server.c
index f703b177385..29adea2574a 100644
--- a/src/uri/sock_test_server.c
+++ b/src/uri/sock_test_server.c
@@ -514,9 +514,15 @@ main (int argc, char **argv)
continue;
}
- else if (strlen ((char *) conn->buf))
- printf ("\nSERVER (fd %d): RX (%d bytes) - '%s'\n",
- conn->fd, rx_bytes, conn->buf);
+ else if (((char *) conn->buf)[0] != 0)
+ {
+ // If it looks vaguely like a string, make sure it's terminated
+ ((char *) conn->buf)[rx_bytes <
+ conn->buf_size ? rx_bytes :
+ conn->buf_size - 1] = 0;
+ printf ("\nSERVER (fd %d): RX (%d bytes) - '%s'\n",
+ conn->fd, rx_bytes, conn->buf);
+ }
}
else // rx_bytes < 0
{
diff --git a/src/uri/vppcom.c b/src/uri/vppcom.c
index aec1295f1b3..aa307f1d333 100644
--- a/src/uri/vppcom.c
+++ b/src/uri/vppcom.c
@@ -1369,23 +1369,18 @@ vppcom_cfg_heapsize (char *conf_fname)
argc++;
char **tmp = realloc (argv, argc * sizeof (char *));
if (tmp == NULL)
- {
- fclose (fp);
- goto defaulted;
- }
+ goto defaulted;
argv = tmp;
arg = strndup (p, 1024);
if (arg == NULL)
- {
- fclose (fp);
- goto defaulted;
- }
+ goto defaulted;
argv[argc - 1] = arg;
p = strtok (NULL, " \t\n");
}
}
fclose (fp);
+ fp = NULL;
char **tmp = realloc (argv, (argc + 1) * sizeof (char *));
if (tmp == NULL)
@@ -1438,6 +1433,10 @@ vppcom_cfg_heapsize (char *conf_fname)
}
defaulted:
+ if (fp != NULL)
+ fclose (fp);
+ if (argv != NULL)
+ free (argv);
if (!clib_mem_init (0, vcl_cfg->heapsize))
clib_warning ("[%d] vppcom heap allocation failure!", vcm->my_pid);
else if (VPPCOM_DEBUG > 0)
@@ -1687,7 +1686,7 @@ input_done:
unformat_free (input);
file_done:
- if (fd > 0)
+ if (fd >= 0)
close (fd);
}