]> git.sur5r.net Git - i3/i3status/commitdiff
slurp(): null-terminate buffer (Thanks mist)
authorMichael Stapelberg <michael@stapelberg.de>
Wed, 13 Jul 2011 17:17:24 +0000 (19:17 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 13 Jul 2011 17:17:24 +0000 (19:17 +0200)
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;
 
         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;
         (void)close(fd);
 
         return true;