Skip to content

Commit 14d1095

Browse files
committed
make sure the actual length of the argument passed matches the
length of the argument declared this fixes things like `php --zend-exten=1` or `php-fpm --fpm-con=conf`
1 parent c0531d8 commit 14d1095

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

main/getopt.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,15 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char
107107
break;
108108
}
109109
}
110-
optchr = 0;
111-
dash = 0;
112-
arg_start += strlen(opts[php_optidx].opt_name);
110+
111+
if (arg_end == strlen(opts[php_optidx].opt_name)) {
112+
optchr = 0;
113+
dash = 0;
114+
arg_start += strlen(opts[php_optidx].opt_name);
115+
} else {
116+
(*optind)++;
117+
return (php_opt_error(argc, argv, *optind-1, optchr, OPTERRNF, show_err));
118+
}
113119
} else {
114120
if (!dash) {
115121
dash = 1;

0 commit comments

Comments
 (0)