libtracectl: add \0 at end of received msg
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Mon, 23 Feb 2009 20:14:06 +0000 (15:14 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Mon, 23 Feb 2009 20:14:06 +0000 (15:14 -0500)
libtracectl/tracectl.c

index a2521585b336f204d56cf1ef7b8489d18d242578..a25bd3b214dd0018b2765f3363ec2296e7d6a4de 100644 (file)
@@ -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);
 
This page took 0.029159 seconds and 4 git commands to generate.