X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fnc_bloaty.c;h=d184f689b57479f26e8ca33e5cfc0fc4475597fc;hb=d38ca03946000f0837e9a0e04937499509db54c4;hp=c44133b5d15a163b35048078f1c755b880667440;hpb=77cc2c5738d780b97b56af49510ed64d61ad2e2d;p=oweals%2Fbusybox.git diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index c44133b5d..d184f689b 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c @@ -3,7 +3,7 @@ * * Copyright (C) 2007 Denys Vlasenko. * - * Licensed under GPLv2, see file LICENSE in this tarball for details. + * Licensed under GPLv2, see file LICENSE in this source tree. */ /* Author's comments from nc 1.10: @@ -36,16 +36,18 @@ * - source routing * - multiple DNS checks * Functionalty which is different from nc 1.10: - * - Prog in '-e PROG' can have prog's parameters and options. + * - PROG in '-e PROG' can have ARGS (and options). * Because of this -e option must be last. - * - nc doesn't redirect stderr to the network socket for the -e PROG. +//TODO: remove -e incompatibility? + * - we don't redirect stderr to the network socket for the -e PROG. + * (PROG can do it itself if needed, but sometimes it is NOT wanted!) * - numeric addresses are printed in (), not [] (IPv6 looks better), * port numbers are inside (): (1.2.3.4:5678) * - network read errors are reported on verbose levels > 1 * (nc 1.10 treats them as EOF) * - TCP connects from wrong ip/ports (if peer ip:port is specified * on the command line, but accept() says that it came from different addr) - * are closed, but nc doesn't exit - continues to listen/accept. + * are closed, but we don't exit - we continue to listen/accept. */ /* done in nc.c: #include "libbb.h" */ @@ -55,10 +57,10 @@ //usage:#define nc_trivial_usage //usage: "[OPTIONS] HOST PORT - connect" //usage: IF_NC_SERVER("\n" -//usage: "nc [OPTIONS] -l -p PORT [HOST] [PORT] - listen") +//usage: "nc [OPTIONS] -l -p PORT [HOST] [PORT] - listen" +//usage: ) //usage:#define nc_full_usage "\n\n" -//usage: "Options:" -//usage: "\n -e PROG Run PROG after connect (must be last)" +//usage: " -e PROG Run PROG after connect (must be last)" //usage: IF_NC_SERVER( //usage: "\n -l Listen mode, for inbound connects" //usage: ) @@ -265,8 +267,7 @@ static int doexec(char **proggie) dup2(0, 1); /* dup2(0, 2); - do we *really* want this? NO! * exec'ed prog can do it yourself, if needed */ - execvp(proggie[0], proggie); - bb_perror_msg_and_die("can't execute '%s'", proggie[0]); + BB_EXECVP_or_die(proggie); } /* connect_w_timeout: @@ -384,10 +385,10 @@ create new one, and bind() it. TODO */ if (port == 0) { /* "nc -nl -p LPORT RHOST" (w/o RPORT!): * we should accept any remote port */ - set_nport(&remend, 0); /* blot out remote port# */ + set_nport(&remend.u.sa, 0); /* blot out remote port# */ } r = memcmp(&remend.u.sa, &themaddr->u.sa, remend.len); - set_nport(&remend, sv_port); /* restore */ + set_nport(&remend.u.sa, sv_port); /* restore */ if (r != 0) { /* nc 1.10 bails out instead, and its error message * is not suppressed by o_verbose */ @@ -427,8 +428,7 @@ create new one, and bind() it. TODO */ rr = getsockopt(netfd, IPPROTO_IP, IP_OPTIONS, optbuf, &x); if (rr >= 0 && x) { /* we've got options, lessee em... */ - bin2hex(bigbuf_net, optbuf, x); - bigbuf_net[2*x] = '\0'; + *bin2hex(bigbuf_net, optbuf, x) = '\0'; fprintf(stderr, "IP options: %s\n", bigbuf_net); } #endif @@ -484,7 +484,7 @@ static int udptest(void) us to hang forever, and hit it */ o_wait = 5; /* enough that we'll notice?? */ rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0); - set_nport(themaddr, htons(SLEAZE_PORT)); + set_nport(&themaddr->u.sa, htons(SLEAZE_PORT)); connect_w_timeout(rr); /* don't need to restore themaddr's port, it's not used anymore */ close(rr); @@ -763,7 +763,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv) getopt32(argv, "hnp:s:uvw:" IF_NC_SERVER("l") IF_NC_EXTRA("i:o:z"), &str_p, &str_s, &o_wait - IF_NC_EXTRA(, &str_i, &str_o, &o_verbose)); + IF_NC_EXTRA(, &str_i, &str_o), &o_verbose); argv += optind; #if ENABLE_NC_EXTRA if (option_mask32 & OPT_i) /* line-interval time */ @@ -811,7 +811,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv) (themaddr ? themaddr->u.sa.sa_family : AF_UNSPEC), x); if (o_lport) - set_nport(ouraddr, htons(o_lport)); + set_nport(&ouraddr->u.sa, htons(o_lport)); } xmove_fd(x, netfd); setsockopt_reuseaddr(netfd); @@ -856,7 +856,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv) } else { /* Outbound connects. Now we're more picky about args... */ if (!themaddr) - bb_error_msg_and_die("no destination"); + bb_show_usage(); remend = *themaddr; if (o_verbose)