Subject: bin/1183: identd/netbsd.c calls kvm_openfiles with bogus argument
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: netbsd-bugs
Date: 07/02/1995 13:20:02
>Number:         1183
>Category:       bin
>Synopsis:       identd/netbsd.c calls kvm_openfiles with bogus argument
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul  2 13:20:01 1995
>Originator:     John F. Woods
>Organization:
Misanthropes-R-Us
>Release:        June 20, 1995
>Environment:
	
System: NetBSD jfwhome.funhouse.com 1.0A NetBSD 1.0A (JFW) #26: Sat Apr 29 12:08:15 EDT 1995 jfw@jfwhome.funhouse.com:/usr/src/sys/arch/i386/compile/JFW i386


>Description:
	If identd cannot open /dev/mem or other assorted files, it gets
signal 10.  identd/netbsd.c is calling kvm_openfiles with a string ("identd")
where kvm_openfiles expects a pointer to a writable array into which it can
copy an error message.
>How-To-Repeat:
	1) backup your root partition onto tape, wipe it out, restore it
	   incorrectly without give pax the "-pe" flag, then reboot and watch
	   identd continually fail with signal 10,
and/or
	2) RTFS then RTFM.
>Fix:
*** netbsd.c.orig	Tue Jun 20 06:35:53 1995
--- netbsd.c	Sun Jul  2 10:13:00 1995
***************
*** 88,99 ****
  
  int k_open()
  {
    /*
    ** Open the kernel memory device
    */
!   if ((kd = kvm_openfiles(path_unix, path_kmem, NULL, O_RDONLY, "identd")) ==
        NULL)
!     ERROR("main: kvm_open");
    
    /*
    ** Extract offsets to the needed variables in the kernel
--- 88,101 ----
  
  int k_open()
  {
+   char errbuf[128];
    /*
    ** Open the kernel memory device
    */
!   strcpy(errbuf, "main: kvm_open: ");
!   if ((kd = kvm_openfiles(path_unix, path_kmem, NULL, O_RDONLY, errbuf+16)) ==
        NULL)
!     ERROR(errbuf);
    
    /*
    ** Extract offsets to the needed variables in the kernel

>Audit-Trail:
>Unformatted: