Subject: pkg/16643: Cupsd dumps core when using empty BrowseProtocols
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kivinen@ssh.fi>
List: netbsd-bugs
Date: 05/03/2002 23:56:07
>Number:         16643
>Category:       pkg
>Synopsis:       Cupsd dumps core when using empty BrowseProtocols
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 03 13:57:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tero Kivinen
>Release:        NetBSD 1.5ZC
>Organization:
SSH Communications Security
>Environment:
System: NetBSD kaakeli.ssh.fi 1.5ZC NetBSD 1.5ZC (KAAKELI) #37: Fri May 3 01:08:56 EEST 2002 root@kaakeli.ssh.fi:/usr/src/sys/arch/i386/compile/KAAKELI i386
Architecture: i386
Machine: i386
>Description:

	I had a configuration file, where I didn't want any support
	for browse protocols, so I left the BrowseProtocols line
	empty. This cause the cupsd to dump core with bus error when
	starting. This was because the StartBrowsing() did check that
	Browsing was enabled, but it did not open any BrowseSocket
	because no cups protocol was enabled. Then the main.c:481 dump
	core because it tried to do if (FD_ISSET(BrowseSocket, &input))
	and the BrowseSocket was -1.

>How-To-Repeat:

	Put following line in the config file and comment out all
	other Browse* options.

	BrowseProtocols

	then start cupsd:

kaakeli (23:35) /usr/pkgsrc/print/cups/work/cups-1.1.14/scheduler#gdb .libs/cupsd 
GNU gdb 5.0nb1
Copyright 2000 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--netbsdelf"...
(gdb) r -f 
Starting program: /usr/pkgsrc/print/cups/work/cups-1.1.14/scheduler/.libs/cupsd -f

Program received signal SIGBUS, Bus error.
0x805f23f in main (argc=2, argv=0xbfbfd694) at main.c:481
481           if (FD_ISSET(BrowseSocket, &input))
(gdb) bt
#0  0x805f23f in main (argc=2, argv=0xbfbfd694) at main.c:481
#1  0x804c240 in ___start ()
(gdb) p BrowseSocket
$1 = -1
(gdb) p input
$2 = {fds_bits = {0, 0, 0, 0, 0, 0, 0, 0}}
(gdb) l
476         * Update the browse list as needed...
477         */
478     
479         if (Browsing)
480         {
481           if (FD_ISSET(BrowseSocket, &input))
482             UpdateCUPSBrowse();
483     
484           if (PollPipe >= 0 && FD_ISSET(PollPipe, &input))
485             UpdatePolling();
(gdb) p Browsing
$3 = 1
(gdb) 

>Fix:

	Either comment out the complete "BrowseProtocols" line or use
	following diff:
----------------------------------------------------------------------
--- main.c.orig	Wed Feb 13 19:21:36 2002
+++ main.c	Fri May  3 23:50:59 2002
@@ -478,7 +478,7 @@
 
     if (Browsing)
     {
-      if (FD_ISSET(BrowseSocket, &input))
+      if (BrowseSocket >= 0 && FD_ISSET(BrowseSocket, &input))
         UpdateCUPSBrowse();
 
       if (PollPipe >= 0 && FD_ISSET(PollPipe, &input))

>Release-Note:
>Audit-Trail:
>Unformatted: