service: make sure string read is null terminated
authorDaniel Golle <daniel@makrotopia.org>
Sun, 15 Aug 2021 11:34:05 +0000 (12:34 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 15 Aug 2021 14:16:23 +0000 (15:16 +0100)
Coverity CID: 1490007 String not null terminated
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
service/service.c

index b3286dc9b2235f0b7f8dff46341e12837e65ad5a..419f96cdf422447f06893148c0cddc50a80d52cc 100644 (file)
@@ -324,6 +324,9 @@ static void put_cgroups(struct blob_buf *b)
                return;
 
        ret = read(fd, &buf, sizeof(buf));
+       /* make sure buffer is NULL-terminated */
+       buf[sizeof(buf)-1] = '\0';
+
        close(fd);
 
        if (ret < 2)