[Bug 12401] New: Problem with argument parsing of "busybox nc" compiled on musl

bugzilla at busybox.net bugzilla at busybox.net
Thu Dec 12 10:38:55 UTC 2019


https://bugs.busybox.net/show_bug.cgi?id=12401

            Bug ID: 12401
           Summary: Problem with argument parsing of "busybox nc" compiled
                    on musl
           Product: Busybox
           Version: 1.31.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: remy at grunblatt.org
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

Created attachment 8316
  --> https://bugs.busybox.net/attachment.cgi?id=8316&action=edit
Busybox .config file

Hello,

I'm using busybox as provided by the Openwrt project, version 1.31.1. The
.config is attached.

Busybox is compiled using "musl".

In my installation (openwrt), it seems the option "-e" is not parsed correctly:


    /tmp/rootfs/mnt # busybox nc 192.168.183.1 12345 -e ./foo.sh
    BusyBox v1.31.1 () multi-call binary.

    Usage: nc [-iN] [-wN] [-l] [-p PORT] [-f FILE|IPADDR PORT] [-e PROG]

    […]

    /tmp/rootfs/mnt # busybox nc -e
    nc: option requires an argument: e
    BusyBox v1.31.1 () multi-call binary.

    […]


When busybox is compiled using "glibc", it works (unless POSIXLY_CORRECT is
set, then it fails in the same way).

People on the Openwrt IRC channel (that basically investigated this bug) argue
that it has to do with the "while (optind < argc)" part: if you put "-e" before
the IPADDR PORT, nc considers IPADDR PORT as parameters of the program. If you
put -e after the IPADDR PORT, then getopt returns EOF when seeing IPADDR PORT
and the code handling the "-e" option isn't hit. They also mention how musl
getopt is different from the getopt from glibc (regarding reshuffling argv) and
it's related.

Rémy

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list