From nobody@FreeBSD.org  Sat Jan 27 04:36:38 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 9504437B401
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 27 Jan 2001 04:36:38 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f0RCacF08874;
	Sat, 27 Jan 2001 04:36:38 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200101271236.f0RCacF08874@freefall.freebsd.org>
Date: Sat, 27 Jan 2001 04:36:38 -0800 (PST)
From: sydney13@mail.com
To: freebsd-gnats-submit@FreeBSD.org
Subject: "mdconfig -t vnode -f floppy.bin" seg fault's
X-Send-Pr-Version: www-1.0

>Number:         24677
>Category:       bin
>Synopsis:       "mdconfig -t vnode -f floppy.bin" seg fault's
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 27 04:40:02 PST 2001
>Closed-Date:    Sun Jan 28 22:12:25 PST 2001
>Last-Modified:  Sun Jan 28 22:12:49 PST 2001
>Originator:     Duncan Idaho
>Release:        FreeBSD 5.0-CURRENT
>Organization:
>Environment:
FreeBSD soleil 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Mon Jan 22 01:51:40 CET 2001     root@soleil:/usr/src/sys/compile/URANUS  i386
>Description:
mdconfig seg fault's when called with "-t vnode -f someflp.bin"

# file floppy.bin
floppy.bin: x86 boot sector, system MSDOS5.0, FAT (12 bit)

# /tmp/mdconfig/mdconfig -a -t vnode -f floppy.bin -u 0
Segmentation fault (core dumped)

# gdb -core mdconfig.core /tmp/mdconfig/mdconfig
GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-freebsd"...
Core was generated by `mdconfig'.
Program terminated with signal 11, Segmentation fault.
#0  0x8048c52 in strncpy (dst=0x0, src=0xbfbffcda "floppy.bin", n=3)
    at /usr/src/lib/libc/../libc/string/strncpy.c:59
59				if ((*d++ = *s++) == 0) {
(gdb) bt
#0  0x8048c52 in strncpy (dst=0x0, src=0xbfbffcda "floppy.bin", n=3)
    at /usr/src/lib/libc/../libc/string/strncpy.c:59
#1  0x80483e0 in main (argc=8, argv=0xbfbffbb0) at mdconfig.c:87
#2  0x8048135 in _start ()
(gdb) quit
>How-To-Repeat:
Use the FreeBSD boot floppy image (or any other) and do:

mdconfig -a -t vnode -f boot.flp -u 0
>Fix:


>Release-Note:
>Audit-Trail:

From: Dima Dorfman <dima@unixfreak.org>
To: sydney13@mail.com
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/24677: "mdconfig -t vnode -f floppy.bin" seg fault's 
Date: Sat, 27 Jan 2001 11:34:59 -0800

 > 
 > >Number:         24677
 > >Category:       bin
 > >Synopsis:       "mdconfig -t vnode -f floppy.bin" seg fault's
 > >How-To-Repeat:
 > Use the FreeBSD boot floppy image (or any other) and do:
 > 
 > mdconfig -a -t vnode -f boot.flp -u 0
 
 I was just going to mail a fix for this to -current or -hackers.  It's
 attached below if you want to test it.
 
 The problem is that mdconfig thinks md_file in struct mdioctl is an
 array while it's really a pointer.
 
 					Dima Dorfman
 					dima@unixfreak.org
 
 > >Fix:
 
 Index: mdconfig.c
 ===================================================================
 RCS file: /st/src/FreeBSD/src/sbin/mdconfig/mdconfig.c,v
 retrieving revision 1.4
 diff -u -r1.4 mdconfig.c
 --- mdconfig.c	2001/01/01 23:08:20	1.4
 +++ mdconfig.c	2001/01/27 19:32:40
 @@ -84,7 +84,7 @@
  		case 'f':
  			if (cmdline != 2)
  				usage();
 -			strncpy(mdio.md_file, optarg, sizeof(mdio.md_file) - 1);
 +			mdio.md_file = optarg;
  			break;
  		case 'o':
  			if (cmdline != 2)
 

From: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: sydney13@mail.com
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/24677: "mdconfig -t vnode -f floppy.bin" seg fault's 
Date: Sun, 28 Jan 2001 19:03:09 +0100

 >>Synopsis:       "mdconfig -t vnode -f floppy.bin" seg fault's
 
 Your mdconfig and kernel are out of sync.  Make sure to build world
 or at least includes.
 
 --
 Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
 phk@FreeBSD.ORG         | TCP/IP since RFC 956
 FreeBSD committer       | BSD since 4.3-tahoe    
 Never attribute to malice what can adequately be explained by incompetence.
 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sun Jan 28 22:12:25 PST 2001 
State-Changed-Why:  
fixed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24677 
>Unformatted:
