]> granicus.if.org Git - php/commitdiff
make sure the actual length of the argument passed matches the
authorAntony Dovgal <tony2001@php.net>
Thu, 8 Apr 2010 15:27:21 +0000 (15:27 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 8 Apr 2010 15:27:21 +0000 (15:27 +0000)
length of the argument declared
this fixes things like `php --zend-exten=1` or `php-fpm --fpm-con=conf`

main/getopt.c

index 1f0be6842e46e21639281c259b1c4311c0b576df..c40d4607ace642d33c278501a5d4c30e0fe99f5d 100644 (file)
@@ -107,9 +107,15 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char
                                break;
                        }
                }
-               optchr = 0;
-               dash = 0;
-               arg_start += strlen(opts[php_optidx].opt_name);
+
+               if (arg_end == strlen(opts[php_optidx].opt_name)) {
+                       optchr = 0;
+                       dash = 0;
+                       arg_start += strlen(opts[php_optidx].opt_name);
+               } else {
+                       (*optind)++;
+                       return (php_opt_error(argc, argv, *optind-1, optchr, OPTERRNF, show_err));
+               }
        } else {
                if (!dash) {
                        dash = 1;