[asterisk-bugs] [JIRA] (ASTERISK-27773) Command line not being parsed correctly with getopt not from glibc

Corey Farrell (JIRA) noreply at issues.asterisk.org
Mon Mar 26 07:04:39 CDT 2018


     [ https://issues.asterisk.org/jira/browse/ASTERISK-27773?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Corey Farrell updated ASTERISK-27773:
-------------------------------------

    Assignee: Guido Falsi

> Command line not being parsed correctly with getopt not from glibc
> ------------------------------------------------------------------
>
>                 Key: ASTERISK-27773
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27773
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Core/General
>    Affects Versions: 15.0.0, 15.3.0
>         Environment: FreeBSD 11.1
>            Reporter: Guido Falsi
>            Assignee: Guido Falsi
>
> Asterisk 15 intriduces a two step command line parsing with getopt(3). Before calling getopt for the second time optind = 0 is called to reset the parsing engine. This works with glibc getopt implementation since it forces optind = 1 when optind == 0 [1]. That's wrong with other implementations not forcing the value to 1.
> FreeBSD's getopt when getting optind == 0 checks if argv[0] is an option and since that fails (except the unrealistic case when argv[0][0] == '-') and stops parsing the rest of the command line. [2]
> I'm going to file patches on gerrit shortly.
> [1] https://github.com/bminor/glibc/blob/2d813d7b77ba8341a0a982d74bb59f5a0d775784/posix/getopt.c#L387
> [2] https://github.com/freebsd/freebsd/blob/5c40d602eef148e8d4231cda313ea122738096f4/lib/libc/stdlib/getopt.c#L72



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list