Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/networking/nc_bloaty.c

    r2725 r3232  
    6161//usage:    )
    6262//usage:#define nc_full_usage "\n\n"
    63 //usage:       "Options:"
    64 //usage:     "\n    -e PROG Run PROG after connect (must be last)"
     63//usage:       "    -e PROG Run PROG after connect (must be last)"
    6564//usage:    IF_NC_SERVER(
    6665//usage:     "\n    -l  Listen mode, for inbound connects"
     
    117116    unsigned wrote_net;          /* total net bytes */
    118117#endif
     118    char *proggie0saved;
    119119    /* ouraddr is never NULL and goes through three states as we progress:
    120120     1 - local address before bind (IP/port possibly zero)
     
    129129    jmp_buf jbuf;                /* timer crud */
    130130
    131     /* will malloc up the following globals: */
    132131    fd_set ding1;                /* for select loop */
    133132    fd_set ding2;
     
    161160/* Must match getopt32 call! */
    162161enum {
    163     OPT_h = (1 << 0),
    164     OPT_n = (1 << 1),
    165     OPT_p = (1 << 2),
    166     OPT_s = (1 << 3),
    167     OPT_u = (1 << 4),
    168     OPT_v = (1 << 5),
    169     OPT_w = (1 << 6),
    170     OPT_l = (1 << 7) * ENABLE_NC_SERVER,
    171     OPT_i = (1 << (7+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
    172     OPT_o = (1 << (8+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
    173     OPT_z = (1 << (9+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
     162    OPT_n = (1 << 0),
     163    OPT_p = (1 << 1),
     164    OPT_s = (1 << 2),
     165    OPT_u = (1 << 3),
     166    OPT_v = (1 << 4),
     167    OPT_w = (1 << 5),
     168    OPT_l = (1 << 6) * ENABLE_NC_SERVER,
     169    OPT_i = (1 << (6+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
     170    OPT_o = (1 << (7+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
     171    OPT_z = (1 << (8+ENABLE_NC_SERVER)) * ENABLE_NC_EXTRA,
    174172};
    175173
     
    265263static int doexec(char **proggie)
    266264{
     265    if (G.proggie0saved)
     266        proggie[0] = G.proggie0saved;
    267267    xmove_fd(netfd, 0);
    268268    dup2(0, 1);
    269269    /* dup2(0, 2); - do we *really* want this? NO!
    270270     * exec'ed prog can do it yourself, if needed */
    271     execvp(proggie[0], proggie);
    272     bb_perror_msg_and_die("can't execute '%s'", proggie[0]);
     271    BB_EXECVP_or_die(proggie);
    273272}
    274273
     
    388387                    /* "nc -nl -p LPORT RHOST" (w/o RPORT!):
    389388                     * we should accept any remote port */
    390                     set_nport(&remend, 0); /* blot out remote port# */
     389                    set_nport(&remend.u.sa, 0); /* blot out remote port# */
    391390                }
    392391                r = memcmp(&remend.u.sa, &themaddr->u.sa, remend.len);
    393                 set_nport(&remend, sv_port); /* restore */
     392                set_nport(&remend.u.sa, sv_port); /* restore */
    394393                if (r != 0) {
    395394                    /* nc 1.10 bails out instead, and its error message
     
    431430        rr = getsockopt(netfd, IPPROTO_IP, IP_OPTIONS, optbuf, &x);
    432431        if (rr >= 0 && x) {    /* we've got options, lessee em... */
    433             bin2hex(bigbuf_net, optbuf, x);
    434             bigbuf_net[2*x] = '\0';
     432            *bin2hex(bigbuf_net, optbuf, x) = '\0';
    435433            fprintf(stderr, "IP options: %s\n", bigbuf_net);
    436434        }
     
    488486        o_wait = 5;                     /* enough that we'll notice?? */
    489487        rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0);
    490         set_nport(themaddr, htons(SLEAZE_PORT));
     488        set_nport(&themaddr->u.sa, htons(SLEAZE_PORT));
    491489        connect_w_timeout(rr);
    492490        /* don't need to restore themaddr's port, it's not used anymore */
     
    730728    char *str_p, *str_s;
    731729    IF_NC_EXTRA(char *str_i, *str_o;)
    732     char *themdotted = themdotted; /* gcc */
     730    char *themdotted = themdotted; /* for compiler */
    733731    char **proggie;
    734732    int x;
     
    758756            goto e_found;
    759757        }
     758        /* -<other_opts>e PROG [ARGS] ? */
     759        /* (aboriginal linux uses this form) */
     760        if (proggie[0][0] == '-') {
     761            char *optpos = *proggie + 1;
     762            /* Skip all valid opts w/o params */
     763            optpos = optpos + strspn(optpos, "nuv"IF_NC_SERVER("l")IF_NC_EXTRA("z"));
     764            if (*optpos == 'e' && !optpos[1]) {
     765                *optpos = '\0';
     766                proggie++;
     767                G.proggie0saved = *proggie;
     768                *proggie = NULL; /* terminate argv for getopt32 */
     769                goto e_found;
     770            }
     771        }
    760772    }
    761773    proggie = NULL;
     
    764776    // -g -G -t -r deleted, unimplemented -a deleted too
    765777    opt_complementary = "?2:vv:w+"; /* max 2 params; -v is a counter; -w N */
    766     getopt32(argv, "hnp:s:uvw:" IF_NC_SERVER("l")
     778    getopt32(argv, "np:s:uvw:" IF_NC_SERVER("l")
    767779            IF_NC_EXTRA("i:o:z"),
    768780            &str_p, &str_s, &o_wait
     
    815827                x);
    816828        if (o_lport)
    817             set_nport(ouraddr, htons(o_lport));
     829            set_nport(&ouraddr->u.sa, htons(o_lport));
    818830    }
    819831    xmove_fd(x, netfd);
Note: See TracChangeset for help on using the changeset viewer.