From 659af8f0efd2d03531be41f5b9820aeb04360470 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 23 Sep 2009 14:05:38 +0200 Subject: [PATCH] terminate string after reading file in whiptail --- whiptail.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 2.47.2