Bug 10991 - getops error in nc if compiled without NC_SERVER
Summary: getops error in nc if compiled without NC_SERVER
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.28.x
Hardware: All Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-07 08:33 UTC by Frank Vosseler
Modified: 2018-07-04 13:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.