From vova@sw.ru  Mon Dec 23 01:49:52 2002
Return-Path: <vova@sw.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0851E37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Dec 2002 01:49:51 -0800 (PST)
Received: from vbook.express.ru (asplinux.ru [195.133.213.194])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2E39E43EE8
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Dec 2002 01:49:51 -0800 (PST)
	(envelope-from vova@sw.ru)
Received: from vova by vbook.express.ru with local (Exim 4.10)
	id 18QPDZ-0000Ie-00
	for FreeBSD-gnats-submit@freebsd.org; Mon, 23 Dec 2002 12:49:49 +0300
Message-Id: <E18QPDZ-0000Ie-00@vbook.express.ru>
Date: Mon, 23 Dec 2002 12:49:49 +0300
From: Vladimir B.Grebenschikov <vova@sw.ru>
Sender: "Vladimir B. Grebenschikov" <vova@sw.ru>
Reply-To: Vladimir B.Grebenschikov <vova@sw.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: error parsing usbd.conf by usbd
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         46489
>Category:       bin
>Synopsis:       error parsing usbd.conf by usbd
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 23 01:50:02 PST 2002
>Closed-Date:    Tue Dec 31 01:09:18 PST 2002
>Last-Modified:  Tue Dec 31 01:09:18 PST 2002
>Originator:     Vladimir B. Grebenschikov
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
SWsoft
>Environment:
System: FreeBSD vbook.express.ru 5.0-CURRENT FreeBSD 5.0-CURRENT #13: Mon Dec 23 11:06:09 MSK 2002 root@vbook.express.ru:/usr/obj/usr/local/src/sys/VBOOK i386

Just from CVS (after 5.0-RC2)

usbd.conf:
------------------------------------------------------
# Configuration file the USB daemon.
#

device "Sony DSC-P50 Dicatal Photo Camera"
	vendor  0x054c
	product 0x0010
	attach "/sbin/camcontrol rescan bus 0; /sbin/mount /m/cam"
	detach "/sbin/umount -f /m/cam"

device "UMass storage (floppy)"
	devname "umass0"
	attach "/sbin/camcontrol rescan bus 0; /sbin/mount /m/A"
	detach "/sbin/umount -f /m/A"


device "Keyboard with Mouse"
	vendor  0x046e 
	product 0x6782
	release 0x0100
	attach "/usr/sbin/kbdcontrol -k /dev/kbd1 -r fast < /dev/ttyv0"
	detach "/usr/sbin/kbdcontrol -k /dev/kbd0 -r fast < /dev/ttyv0"

#
device "Mouse"
	devname "ums[0-9]+"
	attach "/usr/sbin/moused -p /dev/${DEVNAME} -I /var/run/moused.${DEVNAME}.pid -m 6=4 -m 7=5"
	detach "kill /var/run/moused.${DEVNAME}.pid"
#
device "Keyboard"
	devname "ukbd[0-9]+"
	attach "/usr/sbin/kbdcontrol -k /dev/kbd1"
	detach "/usr/sbin/kbdcontrol -k /dev/kbd0"

#
device "USB device"
------------------------------------------------------

>Description:
# usbd
Segmentation fault (core dumped)
# gdb /usr/obj/usr/local/src/usr.sbin/usbd/usbd
...
(gdb) r
Starting program: /usr/obj/usr/local/src/usr.sbin/usbd/usbd 

Program received signal SIGSEGV, Segmentation fault.
0x280fc023 in strncpy () from /usr/lib/libc.so.5
(gdb) bt
#0  0x280fc023 in strncpy () from /usr/lib/libc.so.5
#1  0x080494cd in read_configuration () at
/usr/local/src/usr.sbin/usbd/usbd.c:468
#2  0x0804aa3e in main (argc=0, argv=0xbfbff8d8) at
/usr/local/src/usr.sbin/usbd/usbd.c:1052
#3  0x08048d35 in _start ()
(gdb) up 1
#1  0x080494cd in read_configuration () at
/usr/local/src/usr.sbin/usbd/usbd.c:468
468                     strncpy(linez, line, len);
(gdb) p linez
$1 = 0x800 <Error reading address 0x800: Bad address>
(gdb) p line
$2 = 0x804f15e "device \"Keyboard with Mouse\"\n\tvendor  0x046e \n\tproduct
0x6782\n\trelease 0x0100\n\tattach \"/usr/sbin/kbdcontrol -k /dev/kbd1 -r
fast < /dev/ttyv0\"\n\tdetach \"/usr/sbin/kbdcontrol -k /dev/kbd0 -r fast <
/dev"...
(gdb) p len 
$3 = -1
(gdb) 

Adding one comment into config file fixes problem:
--- /etc/usbd.conf      Mon Dec 23 12:41:39 2002
+++ /etc/usbd.conf.work Mon Dec 23 10:14:30 2002
@@ -12,7 +12,7 @@
        attach "/sbin/camcontrol rescan bus 0; /sbin/mount /m/A"
        detach "/sbin/umount -f /m/A"
 
-
+#
 device "Keyboard with Mouse"
        vendor  0x046e 
        product 0x6782

# usbd -c /etc/usbd.conf.work
#

>How-To-Repeat:
Just try my usbd.conf

>Fix:
>Release-Note:
>Audit-Trail:

From: Maxim Konovalov <maxim@macomnet.ru>
To: "Vladimir B.Grebenschikov" <vova@sw.ru>
Cc: bug-followup@freebsd.org
Subject: Re: bin/46489: error parsing usbd.conf by usbd
Date: Mon, 23 Dec 2002 14:03:00 +0300 (MSK)

 Please try a patch below.
 
 Index: usbd.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/usbd/usbd.c,v
 retrieving revision 1.24
 diff -u -r1.24 usbd.c
 --- usbd.c	22 Apr 2002 13:44:47 -0000	1.24
 +++ usbd.c	23 Dec 2002 10:58:04 -0000
 @@ -448,7 +448,7 @@
  		}
 
  		/* skip initial spaces */
 -		while (*line != '\0' && isspace(*line)) {
 +		while (len > 0 && isspace(*line)) {
  			line++;
  			len--;
  		}
 
 %%%
 
 -- 
 Maxim Konovalov, MAcomnet, Internet Dept., system engineer
 phone: +7 (095) 796-9079, mailto:maxim@macomnet.ru
 
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Tue Dec 24 03:58:25 PST 2002 
State-Changed-Why:  
Fixed in rev. 1.25 src/usr.sbin/usbd/usbd.c in -CURRENT. 


Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Tue Dec 24 03:58:25 PST 2002 
Responsible-Changed-Why:  
Will MFC the fix in one week. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46489 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Tue Dec 31 01:08:33 PST 2002 
State-Changed-Why:  
Fixed in rev. 1.25 and rev. 1.10.2.6 src/usr.sbin/usbd/usbd.c in -CURRENT 
and -STABLE. 

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