Subject: bin/3281: inetd uses wrong (old) size to bind UNIX domain socket
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@ba2.so-net.or.jp>
List: netbsd-bugs
Date: 03/03/1997 22:30:45
>Number:         3281
>Category:       bin
>Synopsis:       inetd uses wrong (old) size to bind UNIX domain socket
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar  3 06:20:02 1997
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
	An individual
>Release:        NetBSD-current 1997 Mar01
>Environment:
System: NetBSD pavlov.enami.ba2.so-net.or.jp 1.2C NetBSD 1.2C (PAVLOV) #164: Sat Feb 8 01:00:12 JST 1997 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/PAVLOV i386


>Description:
	Inetd uses wrong size to bind UNIX domain socket.  It uses
	strlen + sizeof sun_family as a size.  That was correct in old
	dayes, but now (after sun_len is introduced) it is not
	sufficient.
>How-To-Repeat:
	Read the source.
>Fix:
	Here is my fix.

Index: inetd.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.1.1.8
diff -c -r1.1.1.8 inetd.c
*** inetd.c	1997/01/13 15:19:12	1.1.1.8
--- inetd.c	1997/03/03 13:23:38
***************
*** 695,702 ****
  				n = sizeof sep->se_ctrladdr_un.sun_path - 1;
  			strncpy(sep->se_ctrladdr_un.sun_path, sep->se_service, n);
  			sep->se_ctrladdr_un.sun_family = AF_UNIX;
! 			sep->se_ctrladdr_size = n +
! 					sizeof sep->se_ctrladdr_un.sun_family;
  			setup(sep);
  			break;
  		case AF_INET:
--- 695,701 ----
  				n = sizeof sep->se_ctrladdr_un.sun_path - 1;
  			strncpy(sep->se_ctrladdr_un.sun_path, sep->se_service, n);
  			sep->se_ctrladdr_un.sun_family = AF_UNIX;
! 			sep->se_ctrladdr_size = SUN_LEN(&sep->se_ctrladdr_un);
  			setup(sep);
  			break;
  		case AF_INET:
>Audit-Trail:
>Unformatted: