Bug 2245 - nc needs to support -k (multiple listen) BSD extension
Summary: nc needs to support -k (multiple listen) BSD extension
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.16.x
Hardware: Other Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-19 14:38 UTC by Nick Leverton
Modified: 2013-02-28 11:20 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:


Attachments
Patch from sourceforge to fix "Total ports=-1" error (1000 bytes, patch)
2010-07-19 14:38 UTC, Nick Leverton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Leverton 2010-07-19 14:38:42 UTC
Created attachment 2251 [details]
Patch from sourceforge to fix "Total ports=-1" error

GNU netcat doesn't work on avr32, ARM, Macs or other differently-endian machines, but just silently exits without connecting.  The routine for checking which ports are in use is buggy and has problems with unwanted sign-extension.  If you enable debug messaging, the error given is

  (debug) Arguments parsing complete! Total ports=-1 

See http://sourceforge.net/tracker/?func=detail&aid=1068324&group_id=52204&atid=466046
and
http://sourceforge.net/tracker/?func=detail&aid=1205729&group_id=52204&atid=466046

The attached patch is a reformatted version of the fix on Sourceforge.  I've confirmed that it works on AVR32 at least.
Comment 1 Denys Vlasenko 2010-07-20 02:24:31 UTC
How is this related to busybox?
Comment 2 Nick Leverton 2010-07-20 06:18:26 UTC
I apologise, I meant to file it under buildroot.  My mistake.
Comment 3 Peter Korsgaard 2010-07-20 07:00:58 UTC
Committed, thanks.

Out of interest, why are you using the old "big" netcat version instead of the busybox applet?
Comment 4 Nick Leverton 2010-07-20 07:41:03 UTC
Hi, thankyou for the commit.

To be honest I missed that busybox implements nc - except my subconscious obviously remembered since I mis-filed this bug in the first place !  Thanks, I'll check out its features to see if it can do what I need.

I was looking for a netcat version which is flag-compatible with OpenBSD netcat to ease the porting of some scripts.  I needed -k (keep listening after first connection closes) so I've been through the various netcats to check how they behaved without that option.  GNU netcat doesn't have -k, but since it's in the tree already I figured I might as well submit the fix to make it run.

I've now got BSD netcat on my target anyway, the Debian patches to build it under Linux work pretty well for buildroot too.  I can submit the package if you are at all interested in having a third nc implementation in buildroot  ...
Comment 5 Peter Korsgaard 2010-07-20 10:59:30 UTC
(In reply to comment #4)

> I've now got BSD netcat on my target anyway, the Debian patches to build it
> under Linux work pretty well for buildroot too.  I can submit the package if
> you are at all interested in having a third nc implementation in buildroot  ...

Thanks, but to be honest - Not really.
Comment 6 Denys Vlasenko 2010-07-21 13:26:35 UTC
Hijacking this bug for my own evil plans :D
Comment 7 Denys Vlasenko 2013-02-28 11:20:58 UTC
Fixed in git:

commit de6f14800675cd0401106876da81da7618de71c6
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Thu Feb 28 12:20:06 2013 +0100

    nc_bloaty: support -ll and -lk. Closes 2245