]> git.sur5r.net Git - i3/i3status/blobdiff - src/general.c
slurp(): null-terminate buffer (Thanks mist)
[i3/i3status] / src / general.c
index 2ae90f135ed2dad3f6ff788e2905af0b345aa3f1..bf7afd1ec25b24c972a1db531a179e6a4f98a4ba 100644 (file)
@@ -19,7 +19,9 @@ bool slurp(const char *filename, char *destination, int size) {
         if ((fd = open(filename, O_RDONLY)) == -1)
                 return false;
 
-        (void)read(fd, destination, size);
+        int n = read(fd, destination, size);
+        if (n != -1)
+                destination[n] = '\0';
         (void)close(fd);
 
         return true;