From owner-freebsd-bugs@FreeBSD.ORG Fri Jul 9 02:40:22 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9767F16A4CF for ; Fri, 9 Jul 2004 02:40:22 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 743E243D39 for ; Fri, 9 Jul 2004 02:40:22 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i692eMQg025124 for ; Fri, 9 Jul 2004 02:40:22 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i692eMMr025123; Fri, 9 Jul 2004 02:40:22 GMT (envelope-from gnats) Resent-Date: Fri, 9 Jul 2004 02:40:22 GMT Resent-Message-Id: <200407090240.i692eMMr025123@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Nelson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ADE4F16A4CE for ; Fri, 9 Jul 2004 02:38:41 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6906B43D2D for ; Fri, 9 Jul 2004 02:38:41 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i692ce5R019205; Thu, 8 Jul 2004 21:38:40 -0500 (CDT) (envelope-from dan) Message-Id: <200407090238.i692ce5R019205@dan.emsphone.com> Date: Thu, 8 Jul 2004 21:38:40 -0500 (CDT) From: Dan Nelson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/68839: [PATCH] gcore hangs on current X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dan Nelson List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jul 2004 02:40:22 -0000 >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@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 $$ $ >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: