Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sat, 24 Feb 2018 10:09:18 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: test-getopt-posix fails on musl

On Sat, Feb 24, 2018 at 10:31:55AM +0100, Bruno Haible wrote:
> Hi,
> 
> On Alpine Linux 3.7.0, which uses musl libc, the gnulib test 'test-getopt-posix'
> fails. To me, this looks like a POSIX compliance bug of musl.
> Find attached a reduced test case.
> 
> $ gcc foo.c -Wall
> $ ./a.ou	t
> foo.c:134: assertion 'options[0] == ':' || ((options[0] == '-' || options[0] == '+') && options[1] == ':')' failed
> 
> Reference: POSIX
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html

It seems like the behavior you're claiming is wrong is that getopt is
treating ':' in the optstring as a valid option rather than just a
modifier to the option character before it or the special flag at the
beginning of optstring. The likely reason the bug exists is that the
spec isn't clear that colons can't be option characters (maybe they
could be, especially if they're not initial or immediately following
another option character?) but it is clear that characters outside
class alnum are not required to be supported as options, and I think
it's clear that accepting -: is not the right thing to do here.

Attached patch should fix it; if nobody objects right away I'll apply.

Thanks!

Rich


View attachment "getopt-colon.diff" of type "text/plain" (431 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.