diff options
author | jlemon <jlemon@FreeBSD.org> | 2001-06-07 05:26:26 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2001-06-07 05:26:26 +0000 |
commit | 87d6ade9a72dc391f9538f9dde76bf632de17905 (patch) | |
tree | acfca8a2155c523e32b0c9be6b964abe99e01e9a /usr.bin/gcore | |
parent | bd2af8830f0d8658550f9768f5f6f2028698ef86 (diff) | |
download | FreeBSD-src-87d6ade9a72dc391f9538f9dde76bf632de17905.zip FreeBSD-src-87d6ade9a72dc391f9538f9dde76bf632de17905.tar.gz |
Null terminate buffer.
PR: 23150
Submitted by: Dan Nelson <dnelson@emsphone.com>
MFC in: 1 week
Diffstat (limited to 'usr.bin/gcore')
-rw-r--r-- | usr.bin/gcore/elfcore.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index 4cb5f0f..1d57db9 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; |