]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
terminate string after reading file in whiptail
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 23 Sep 2009 12:05:38 +0000 (14:05 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 23 Sep 2009 12:05:38 +0000 (14:05 +0200)
whiptail.c

index dbf2588c323f3d61b54fc72cf6e31da7e999c7cb..95213404e8892915a1921d2848281ef94a04a4ff 100644 (file)
@@ -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;
 }