bin/68839: [PATCH] gcore hangs on current
Dan Nelson
dan at dan.emsphone.com
Thu Jul 8 19:40:22 PDT 2004
>Number: 68839
>Category: bin
>Synopsis: [PATCH] gcore hangs on current
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 09 02:40:22 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator: Dan Nelson
>Release: FreeBSD 5.2-CURRENT i386
>Organization:
The Allant Group
>Environment:
System: FreeBSD dan.emsphone.com 5.2-CURRENT FreeBSD 5.2-CURRENT #341: Wed Jun 23 23:03:45 CDT 2004 zsh at dan.emsphone.com:/usr/src/sys/i386/compile/DANSMP i386
>Description:
The 2003/09/29 commit to procfs_map.c added a column to /proc/*/map.
This breaks gcore, which ends up in an infinite loop trying to parse
the first line of the mapfile over and over and over with the wrong
number of fields.
>How-To-Repeat:
$ gcore $$
<wait forever>
$
>Fix:
Parse the new field, and add a sanity check that we scanned a nonzero
number of characters so when someone changes the format of /proc/*/map
again gcore will catch it. gcore should probably be rewritten to not
use /procfs.
Index: elfcore.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/gcore/elfcore.c,v
retrieving revision 1.16
diff -u -r1.16 elfcore.c
--- elfcore.c 15 Feb 2004 22:48:25 -0000 1.16
+++ elfcore.c 9 Jul 2004 02:16:54 -0000
@@ -504,10 +504,10 @@
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 */
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list