From: Miroslav Lichvar Date: Wed, 23 Sep 2009 12:05:38 +0000 (+0200) Subject: terminate string after reading file in whiptail X-Git-Tag: r0-52-11~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=659af8f0efd2d03531be41f5b9820aeb04360470;p=thirdparty%2Fnewt.git terminate string after reading file in whiptail --- diff --git a/whiptail.c b/whiptail.c index dbf2588..9521340 100644 --- a/whiptail.c +++ b/whiptail.c @@ -305,7 +305,7 @@ readTextFile(const char * filename) exit(DLG_ERROR); } - if ( (buf = malloc(s.st_size)) == 0 ) + if ( (buf = malloc(s.st_size + 1)) == 0 ) fprintf(stderr, _("%s: too large to display.\n"), filename); if ( read(fd, buf, s.st_size) != s.st_size ) { @@ -313,6 +313,7 @@ readTextFile(const char * filename) exit(DLG_ERROR); } close(fd); + buf[s.st_size] = '\0'; return buf; }