summaryrefslogtreecommitdiffstats
path: root/usr.bin/gcore/elfcore.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-07-12 20:19:40 +0000
committerrwatson <rwatson@FreeBSD.org>2004-07-12 20:19:40 +0000
commit91e23d98c534a497b70a4087007fa9d56902f65c (patch)
tree4da0369a41b7cf1f4d1c6d5a236ffdefdf42bf8c /usr.bin/gcore/elfcore.c
parentf1f136454038170d35f84820e4e94cdf61293e89 (diff)
downloadFreeBSD-src-91e23d98c534a497b70a4087007fa9d56902f65c.zip
FreeBSD-src-91e23d98c534a497b70a4087007fa9d56902f65c.tar.gz
Teach gcore about the pathname field of '/proc/*/map' so that it doesn't
spin when its parser gets confused by a lack of end-of-line. Submitted by: Dan Nelson <dan@dan.emsphone.com> PR: 68839
Diffstat (limited to 'usr.bin/gcore/elfcore.c')
-rw-r--r--usr.bin/gcore/elfcore.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c
index c6a161d..4a920eb 100644
--- a/usr.bin/gcore/elfcore.c
+++ b/usr.bin/gcore/elfcore.c
@@ -504,10 +504,10 @@ readmap(pid_t pid)
len = 0;
n = sscanf(mapbuf + pos, "%x %x %*d %*d %*x %3[-rwx]"
- " %*d %*d %*x %*s %*s %16s%*[\n]%n",
+ " %*d %*d %*x %*s %*s %16s %*s%*[\n]%n",
&start, &end, prot, type, &len);
- if (n != 4)
- errx(1, "ill-formed line in %s", mapname);
+ if (n != 4 || len == 0)
+ errx(1, "ill-formed line in %s starting at character %d", mapname, pos + 1);
pos += len;
/* Ignore segments of the wrong kind, and unwritable ones */
OpenPOWER on IntegriCloud