netcat-openbsd does not allow setting source port

Bug #1772014 reported by Aki Rossi
This bug report is a duplicate of:  Bug #1767283: nc doesn't support "-s IP" option. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netcat-openbsd (Ubuntu)
New
Undecided
Unassigned

Bug Description

When connecting to a remote host, both the command-line help and man-page state that specifying `-p` will set the local port number. However, when I actually attempt to do it, only the usage text is printed:

$ nc.openbsd -p 12345 localhost 12345
usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
   [-m minttl] [-O length] [-P proxy_username] [-p source_port]
   [-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout]
   [-X proxy_protocol] [-x proxy_address[:port]] [destination] [port]

This appears to be caused by an erroneous check on line 541 of netcat.c, introduced by `misc-failures-and-features.patch`. If I remove the check or undo the patch completely, the source port is set correctly, but remains bound after I close the connection. Meanwhile, netcat-traditional works as expected.

Aki Rossi (lorkki)
description: updated
Revision history for this message
Aki Rossi (lorkki) wrote :

Oh, and this is Ubuntu 18.04, and package version 1.187-1.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi,
you are right and this is a dup of bug 1767283 which I already fixed in Cosmic and have a backport for Bionic ongoing right now.

Closing this as Dup.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.