summaryrefslogtreecommitdiff
path: root/usr.bin/gcore
diff options
context:
space:
mode:
authorJonathan Lemon <jlemon@FreeBSD.org>2001-06-07 05:26:26 +0000
committerJonathan Lemon <jlemon@FreeBSD.org>2001-06-07 05:26:26 +0000
commit889b293a21533708a02b09cf18ba4850943afbc6 (patch)
treeacfca8a2155c523e32b0c9be6b964abe99e01e9a /usr.bin/gcore
parent0a52f59c3692a91b7b83e147c108ec0186944a74 (diff)
downloadsrc-test2-889b293a21533708a02b09cf18ba4850943afbc6.tar.gz
src-test2-889b293a21533708a02b09cf18ba4850943afbc6.zip
Null terminate buffer.
PR: 23150 Submitted by: Dan Nelson <dnelson@emsphone.com> MFC in: 1 week
Notes
Notes: svn path=/head/; revision=77861
Diffstat (limited to 'usr.bin/gcore')
-rw-r--r--usr.bin/gcore/elfcore.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c
index 4cb5f0f93fe3..1d57db90840c 100644
--- a/usr.bin/gcore/elfcore.c
+++ b/usr.bin/gcore/elfcore.c
@@ -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;