From: "Anthony G. Basile" <basile@freeharbor.net>
To: musl@lists.openwall.com
Subject: bug in getopt_long()
Date: Thu, 5 Jan 2017 11:00:52 -0500 [thread overview]
Message-ID: <61d0bce5-f14a-11d8-022b-a65ff2f5524a@freeharbor.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 795 bytes --]
Hi,
We hit a bug in Gentoo with getopt_long(). It appears the alpine people
hit it too http://bugs.alpinelinux.org/issues/4802. The problem was
encountered in open-iscsi but I got some reduced code which I've
attached. If you build and run that code as `./test --portal
10.144.0.14 --discover` then you get
p
D
unrecognized character 'D'
On a glibc system, you don't get the "unrecognized character 'D'" which
is what we'd expect. Rich suggested a patch to musl which looked like
it might work, but it didn't. I didn't investigate further. I'm just
reporting it first to see if others know what's up.
--
Anthony G. Basile, Ph.D.
Gentoo Linux Developer [Hardened]
E-Mail : basile@freeharbor.net
GnuPG FP : 1FED FAD9 D82C 52A5 3BAB DC79 9384 FA6E F52D 4BBA
GnuPG ID : F52D4BBA
[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 626 bytes --]
#include <getopt.h>
#include <stdio.h>
static struct option const long_options[] =
{
{"portal", required_argument, NULL, 'p'},
{"discover", no_argument, NULL, 'D'},
{NULL, 0, NULL, 0},
};
static char *short_options = "Dp:";
int main(int argc, char **argv)
{
int ch, longindex;
optopt = 0;
while ((ch = getopt_long(argc, argv, short_options, long_options, &longindex)) >= 0) {
switch (ch) {
case 'D':
printf("D\n");
break;
case 'p':
printf("p\n");
}
}
if (optopt)
printf("unrecognized character '%c'\n", optopt);
}
next reply other threads:[~2017-01-05 16:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 16:00 Anthony G. Basile [this message]
2017-01-07 15:13 writeonce
2017-01-07 16:31 writeonce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=61d0bce5-f14a-11d8-022b-a65ff2f5524a@freeharbor.net \
--to=basile@freeharbor.net \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).