aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri/sock_test_server.c
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/sock_test_server.c
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/sock_test_server.c')
-rw-r--r--src/uri/sock_test_server.c12
1 files changed, 9 insertions, 3 deletions
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
{