aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri/sock_test_server.c
diff options
context:
space:
mode:
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
{