[Bug 837] New: netcat does not accept connections when listening for a specified remote host

bugzilla at busybox.net bugzilla at busybox.net
Fri Jan 1 21:07:00 UTC 2010


https://bugs.busybox.net/show_bug.cgi?id=837

           Summary: netcat does not accept connections when listening for a
                    specified remote host
           Product: Busybox
           Version: 1.15.x
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Networking
        AssignedTo: unassigned at busybox.net
        ReportedBy: mikeus at hotmail.ru
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0


Nc does not accept connections when listening for a specified remote host.

The command:
nc -n -l -p <local port> <remote host>
always reports "nc: connect from wrong ip/port ... ignored"

Nc accepts a connection only when a remote source port is specified (and the
connection comes from it):
nc -n -l -p <local port> <remote host> <remote source port>

This is because of 'memcmp' method of checking out the incoming connection
address and port in 'dolisten()' function (line #343 in
networking/nc_bloaty.c):
----------------------------------------
340   rr = accept(netfd, &remend.u.sa, &remend.len);
341   if (rr < 0)
342       bb_perror_msg_and_die("accept");
343   if (themaddr && memcmp(&remend.u.sa, &themaddr->u.sa, remend.len) != 0) {
344       /* nc 1.10 bails out instead, and its error message
345        * is not suppressed by o_verbose */
346       if (o_verbose) {
347           char *remaddr = xmalloc_sockaddr2dotted(&remend.u.sa);
348           bb_error_msg("connect from wrong ip/port %s ignored", remaddr);
349           free(remaddr);
350       }
351       close(rr);
352       goto again;
353   }
----------------------------------------

Here 'themaddr->u.sa' has port=0 if it is not specified on the command line
while 'remend.u.sa' always has nonzero source port


-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list