Commit 56070e55 by Richard Kenner

(read_specs): Use length read when inserting zero.

From-SVN: r8979
parent bc17186d
...@@ -1110,6 +1110,7 @@ read_specs (filename) ...@@ -1110,6 +1110,7 @@ read_specs (filename)
char *filename; char *filename;
{ {
int desc; int desc;
int readlen;
struct stat statbuf; struct stat statbuf;
char *buffer; char *buffer;
register char *p; register char *p;
...@@ -1126,8 +1127,10 @@ read_specs (filename) ...@@ -1126,8 +1127,10 @@ read_specs (filename)
/* Read contents of file into BUFFER. */ /* Read contents of file into BUFFER. */
buffer = xmalloc ((unsigned) statbuf.st_size + 1); buffer = xmalloc ((unsigned) statbuf.st_size + 1);
read (desc, buffer, (unsigned) statbuf.st_size); readlen = read (desc, buffer, (unsigned) statbuf.st_size);
buffer[statbuf.st_size] = 0; if (readlen < 0)
pfatal_with_name (filename);
buffer[readlen] = 0;
close (desc); close (desc);
/* Scan BUFFER for specs, putting them in the vector. */ /* Scan BUFFER for specs, putting them in the vector. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment