Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgi_param_multiple() is broken, potentially causing endless loop in actual usage #37

Open
kennyk-peplink opened this issue Jun 22, 2017 · 3 comments
Labels

Comments

@kennyk-peplink
Copy link

It's typical (if not only) use case:

while ((value = cgi_param_multiple(name)) != NULL) {
// processing here...
}

will cause endless loop when name is found at the end of the CGI parameter list.

@kennyk-peplink
Copy link
Author

6691523

Currently cgi_param_multiple() stored the "next iterator" for repeated usage.
When the last CGI parameter is match and fetched, however, we've got a value and "next iteration" is NULL;
subsequently call will redo a fetching from the start, falling into endless loop.

@kennyk-peplink
Copy link
Author

Suggested fix: Simply store the 'iterator', not the 'next iterator'; if there is a next fetch, start from that iterator's next.

  1. Replace "if (!iter) iter = formvars_start" with,
    iter = iter ? iter->next : formvars_start;

  2. Remove "iter = iter->next;" before break;

@LeSpocky LeSpocky added the bug label Jun 22, 2017
@LeSpocky LeSpocky added this to the v1.2 milestone Jun 22, 2017
@LeSpocky LeSpocky removed this from the v1.2.0 milestone Jul 23, 2018
@LeSpocky
Copy link
Collaborator

Personally I have currently no usecase for cgi_param_multiple(), but I would be happy if you could provide a patch and a testcase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants