X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fgeneral.c;h=c5b33b46f652142dbfad53fdd7a73463c217fd37;hb=562a879f7c40bb7586e2d4b8dc55cf3171e5d43d;hp=2ae90f135ed2dad3f6ff788e2905af0b345aa3f1;hpb=cf091024335052e4774d44179e80e1948da8610f;p=i3%2Fi3status diff --git a/src/general.c b/src/general.c index 2ae90f1..c5b33b4 100644 --- a/src/general.c +++ b/src/general.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "i3status.h" @@ -19,7 +20,10 @@ bool slurp(const char *filename, char *destination, int size) { if ((fd = open(filename, O_RDONLY)) == -1) return false; - (void)read(fd, destination, size); + /* We need one byte for the trailing 0 byte */ + int n = read(fd, destination, size-1); + if (n != -1) + destination[n] = '\0'; (void)close(fd); return true;