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:
parent
0a52f59c36
commit
889b293a21
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77861
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user