hotplug.c: Make sure hotplug buffer is NULL terminated
[project/procd.git] / plug / hotplug.c
index 80e6e4db9e734b708f62d4f41a695486f654188f..799123dcea195b562e7c71dee2197566f0bb6b3c 100644 (file)
@@ -545,11 +545,13 @@ static void hotplug_handler(struct uloop_fd *u, unsigned int ev)
 {
        int i = 0;
        static char buf[4096];
-       int len = recv(u->fd, buf, sizeof(buf), MSG_DONTWAIT);
+       int len = recv(u->fd, buf, sizeof(buf) - 1, MSG_DONTWAIT);
        void *index;
        if (len < 1)
                return;
 
+       buf[len] = '\0';
+
        blob_buf_init(&b, 0);
        index = blobmsg_open_table(&b, NULL);
        while (i < len) {