Bug 6926 - busybox nc segfaults with option -z
Summary: busybox nc segfaults with option -z
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.22.x
Hardware: PC Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-26 07:18 UTC by Andreas
Modified: 2014-02-26 12:59 UTC (History)
2 users (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 Andreas 2014-02-26 07:18:01 UTC
You cannot use busybox nc with Option -z, because -z is mapped to -o, 
e.g. I used the following command, to test if there is a running ssh 
service on somehostname:

busybox nc -w 2 -z somehostname 22 ; echo $?

This fails with a segfaulting busybox. I tracked the error and found
it was introduced with the commit de6f14800675cd0401106876da81da7618de71c6
(nc_bloaty: support -ll and -lk). 

Please apply the following patch to correct this error:

Index: busybox-1.22.1/networking/nc_bloaty.c
===================================================================
--- busybox-1.22.1.orig/networking/nc_bloaty.c
+++ busybox-1.22.1/networking/nc_bloaty.c
@@ -175,9 +175,9 @@ enum {
 	OPT_w = (1 << 5),
 	OPT_l = (1 << 6) * ENABLE_NC_SERVER,
 	OPT_k = (1 << 7) * ENABLE_NC_SERVER,
-	OPT_i = (1 << (7+2*ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
-	OPT_o = (1 << (8+2*ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
-	OPT_z = (1 << (9+2*ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
+	OPT_i = (1 << (6+2*ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
+	OPT_o = (1 << (7+2*ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
+	OPT_z = (1 << (8+2*ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
 };
 
 #define o_nflag   (option_mask32 & OPT_n)
Comment 1 Denys Vlasenko 2014-02-26 12:59:50 UTC
Thanks!
Fixed in git:

commit c472898eaa0ccc1d4d787ae1917a8f40d18889cb
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Wed Feb 26 13:58:59 2014 +0100

    nc: fix option bit positions