From 40f753cd553dff749744910f24e34c6f743e64c6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 20 Aug 1999 05:33:12 +0000 Subject: 1999-08-20 Roland McGrath * bootstrap.c (parse_script): Add one to the buffer size so we can null-terminate after the end of the file. --- serverboot/bootstrap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c index 292bf81b..3057e0a7 100644 --- a/serverboot/bootstrap.c +++ b/serverboot/bootstrap.c @@ -437,7 +437,7 @@ parse_script (struct file *f) int amt, fd, err; int n = 0; - buf = malloc (f->f_size); + buf = malloc (f->f_size + 1); /* add one for null terminator we will write */ if (read_file (f, 0, buf, f->f_size, 0)) panic ("bootstrap: error reading boot script file"); @@ -445,7 +445,7 @@ parse_script (struct file *f) while (1) { while (p < buf + f->f_size && *p != '\n') - p++; + p++; *p = '\0'; err = boot_script_parse_line (line); if (err) @@ -453,7 +453,6 @@ parse_script (struct file *f) if (p == buf + f->f_size) break; line = ++p; - } free (buf); } -- cgit v1.2.3