1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

Null terminate buffer.

PR: 23150
Submitted by: Dan Nelson <dnelson@emsphone.com>
MFC in: 1 week
This commit is contained in:
Jonathan Lemon 2001-06-07 05:26:26 +00:00
parent 0a52f59c36
commit 889b293a21
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77861

View File

@ -455,7 +455,7 @@ readmap(pid_t pid)
bufsize = 8 * 1024;
mapbuf = NULL;
for ( ; ; ) {
if ((mapbuf = realloc(mapbuf, bufsize)) == NULL)
if ((mapbuf = realloc(mapbuf, bufsize + 1)) == NULL)
errx(1, "out of memory");
mapsize = read(mapfd, mapbuf, bufsize);
if (mapsize != -1 || errno != EFBIG)
@ -468,6 +468,7 @@ readmap(pid_t pid)
err(1, "read error from %s", mapname);
if (mapsize == 0)
errx(1, "empty map file %s", mapname);
mapbuf[mapsize] = 0;
close(mapfd);
pos = 0;