From arnej@math.ntnu.no  Thu Feb 11 05:49:13 1999
Received: from romberg.math.ntnu.no (romberg.math.ntnu.no [129.241.15.150])
          by hub.freebsd.org (8.8.8/8.8.8) with SMTP id FAA17624
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 11 Feb 1999 05:49:11 -0800 (PST)
          (envelope-from arnej@math.ntnu.no)
Received: (qmail 10638 invoked from network); 11 Feb 1999 13:49:08 -0000
Received: from fimfpc19.math.ntnu.no (129.241.15.132)
  by romberg.math.ntnu.no with SMTP; 11 Feb 1999 13:49:08 -0000
Received: (from arnej@localhost)
          by fimfpc19.math.ntnu.no (8.9.2/8.8.4)
	  id OAA51855; Thu, 11 Feb 1999 14:49:08 +0100 (CET)
Message-Id: <199902111349.OAA51855@fimfpc19.math.ntnu.no>
Date: Thu, 11 Feb 1999 14:49:08 +0100 (CET)
From: arnej@math.ntnu.no
Reply-To: arnej@math.ntnu.no
To: FreeBSD-gnats-submit@freebsd.org
Subject: kdump prints garbage when command name is too long
X-Send-Pr-Version: 3.2

>Number:         10027
>Category:       bin
>Synopsis:       kdump prints garbage when command name is too long
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 11 05:50:00 PST 1999
>Closed-Date:    Thu May 20 18:10:00 PDT 1999
>Last-Modified:  Thu May 20 18:10:35 PDT 1999
>Originator:     Arne Henrik Juul
>Release:        FreeBSD 3.0-STABLE i386
>Organization:
Norwegian University of Technology and Science
>Environment:

	This looks like a bug that is present in all versions of kdump.c.

>Description:

	When kdump writes the command name, it does not take care to
	only write the bytes that actually belong to that field, so
	it also writes the binary data in following fields until it
	hits a terminating zero somewhere.

>How-To-Repeat:

	cd /tmp
	cp /bin/ls ls-with-a-very-long-name
	ktrace ./ls-with-a-very-long-name ls-with-a-very-long-name
	kdump
	[... typical result ...]
 51810 ls-with-a-very-lname6nb RET   write 25/0x19
 51810 ls-with-a-very-lname6bob CALL  fchdir(0x3)
 51810 ls-with-a-very-lname67ob RET   fchdir 0
 51810 ls-with-a-very-lname6ob CALL  madvise(0x807f000,0x1000,0x5)
 51810 ls-with-a-very-lname6ob RET   madvise 0
 51810 ls-with-a-very-lname6tpb CALL  exit(0)

>Fix:

	Apply this patch:

Index: kdump.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/kdump/kdump.c,v
retrieving revision 1.11
diff -u -r1.11 kdump.c
--- kdump.c	1997/07/16 06:49:49	1.11
+++ kdump.c	1999/02/05 13:18:55
@@ -211,7 +211,7 @@
 		type = unknown;
 	}
 
-	(void)printf("%6d %-8s ", kth->ktr_pid, kth->ktr_comm);
+	(void)printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN, kth->ktr_comm);
 	if (timestamp) {
 		if (timestamp == 2) {
 			temp = kth->ktr_time;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jmz 
State-Changed-When: Thu May 20 18:10:00 PDT 1999 
State-Changed-Why:  
Patch applied. Thanks! 
>Unformatted:
