From: Pierre-Marc Fournier Date: Mon, 23 Feb 2009 20:14:06 +0000 (-0500) Subject: libtracectl: add \0 at end of received msg X-Git-Tag: v1.9.1~1051 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=681a8a78b217685f20a386f77f5d0c76c6701b10;p=lttng-ust.git libtracectl: add \0 at end of received msg --- 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);