]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
core: fix getopt(3) usage
authorGuido Falsi <madpilot@freebsd.org>
Mon, 26 Mar 2018 12:42:52 +0000 (14:42 +0200)
committerGuido Falsi <madpilot@freebsd.org>
Mon, 26 Mar 2018 12:50:37 +0000 (06:50 -0600)
Setting optind = 0 is forced to 1 in glibc implementation, but
causes option parsing to be flawed in other implementations, for
example on FreeBSD.

ASTERISK-27773 #close

Change-Id: Ia548e69f8302e9754dbbedb6bc451c0700c66f61

main/asterisk.c

index 0442614a403f078629976da2206b7cf3b50f54ad..568feb0b6b3033ca0851794a39d7d3d1d2214981 100644 (file)
@@ -3995,7 +3995,7 @@ int main(int argc, char *argv[])
         *
         * \todo Document these options
         */
-       optind = 0;
+       optind = 1;
        while ((c = getopt(argc, argv, getopt_settings)) != -1) {
                /*!\note Please keep the ordering here to alphabetical, capital letters
                 * first.  This will make it easier in the future to select unused