Bug 10991

Summary: getops error in nc if compiled without NC_SERVER
Product: Busybox Reporter: Frank Vosseler <frank.vosseler>
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: major CC: busybox-cvs
Priority: P5    
Version: 1.28.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Frank Vosseler 2018-05-07 08:33:28 UTC
We have built BB without NC_SERVER, i.e. without the '-l' option enabled.  However, when we run nc (e.g. 'nc -vz google.com 80'), we get an error "nc: NO OPT l!"

I suspect this is because the complementary options in nc_bloaty.c define the 'l' option unconditionally in line 794 by mistake:
    790  getopt32(argv, "^"
    791                 "np:s:uvw:+"/* -w N */ IF_NC_SERVER("lk")
    792                 IF_NC_EXTRA("i:o:z")
    793                         "\0"
    794                         "?2:vv:ll", /* max 2 params; -v and -l are counters */

Line 794 should define the complementary option l conditional on NC_SERVER:
"?2:vv" IF_NC_SERVER(":ll"), /* max 2 params; -v and -l are counters */
Comment 1 Frank Vosseler 2018-05-07 08:36:48 UTC
I should have mentioned: we use 1.28.3, downloaded from https://busybox.net/downloads/busybox-1.28.3.tar.
Comment 2 Denys Vlasenko 2018-05-24 14:38:24 UTC
Does this change work?

                IF_NC_EXTRA("i:o:z")
                        "\0"
-                       "?2:vv:ll", /* max 2 params; -v and -l are counters */
+                       "?2:vv"IF_NC_SERVER(":ll"), /* max 2 params; -v and -l are counters */
Comment 3 Frank Vosseler 2018-07-04 08:39:22 UTC
My apologies, I have only noticed now that my email response that I sent back in May to Denys' email did not get attached as a comment, thus my response now also as a comment here:
yes, that line change worked perfectly fine for me, when I built 1.28.3 with that change included.