Subject: bin/8101: inetd doesn't take care of foo[46] in all places
To: None <gnats-bugs@gnats.netbsd.org>
From: None <lha@stacken.kth.se>
List: netbsd-bugs
Date: 07/28/1999 03:14:01
>Number:         8101
>Category:       bin
>Synopsis:       inetd doesn't take care of foo[46] in all places
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 28 02:35:00 1999
>Last-Modified:
>Originator:     Love Hörnquist-Åstrand
>Organization:
Stacken, KTH, Sweden
>Release:        currrent as of Jul 28 1998
>Environment:
NetBSD mulet.e.kth.se 1.4H NetBSD 1.4H

>Description:
Inetd doesn't handle the tcp[46] case and you end up with syslog-
messages like:

Jul 28 10:29:56 mulet inetd[3879]: connection from datan.foo, service 23 (tcp4)

>How-To-Repeat:

use tcp[46] in inetd.conf
>Fix:

--- inetd.c.orig        Wed Jul 28 11:24:37 1999
+++ inetd.c     Wed Jul 28 11:22:43 1999
@@ -660,8 +660,26 @@
                fromhost(&req);
                denied = !hosts_access(&req);
                if (denied || lflag) {
+                       char proto[40];
+                       int i;
+
+                       i = strlen (sep->se_proto);
+
+                       switch (sep->se_proto[i-1]) {
+                       case '4':
+                       case '6':
+                               i = MIN(sizeof(proto),i);
+                               strncpy(proto, sep->se_proto, i);
+                               proto[i-1] = '\0';
+                               break;
+                       default:
+                               strncpy(proto, sep->se_proto, sizeof(proto));
+                               proto[sizeof(proto)-1] = '\0';
+                               break;
+                       }
+
                        sp = getservbyport(sep->se_ctrladdr_in.sin_port,
-                           sep->se_proto);
+                                          proto);
                        if (sp == NULL) {
                                (void)snprintf(buf, sizeof buf, "%d",
                                    ntohs(sep->se_ctrladdr_in.sin_port));

>Audit-Trail:
>Unformatted: