From 681a8a78b217685f20a386f77f5d0c76c6701b10 Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Mon, 23 Feb 2009 15:14:06 -0500 Subject: [PATCH] libtracectl: add \0 at end of received msg --- libtracectl/tracectl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libtracectl/tracectl.c b/libtracectl/tracectl.c index a2521585..a25bd3b2 100644 --- a/libtracectl/tracectl.c +++ b/libtracectl/tracectl.c @@ -228,7 +228,7 @@ int listener_main(void *p) struct trctl_msg msg; int len; - result = len = recvfrom(pfd, recvbuf, sizeof(recvbuf), 0, &addr, &addrlen); + result = len = recvfrom(pfd, recvbuf, sizeof(recvbuf-1), 0, &addr, &addrlen); if(result == -1) { PERROR("recvfrom"); continue; @@ -236,6 +236,8 @@ int listener_main(void *p) if(recvbuf[len-1] == '\n') recvbuf[len-1] = '\0'; + else + recvbuf[len] = 0; fprintf(stderr, "received a message! it's: %s\n", recvbuf); -- 2.34.1