-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix macro invocation with post-increment index as argument #1125
base: master
Are you sure you want to change the base?
Conversation
In WebRequest.cpp at line 150: while (i<len && __is_param_char(((char*)buf)[i++])); the macro __is_param_char will expand producing multiple i++ invocations making the algorithm to (sometimes) fail.
Small bug fix at WebRequest.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree: this looks like a bug. "__is_param_char" macro expansion will cause multiple increments of i++. That is a dangerous macro. Rather than a macro, perhaps we should be using a function here?
bool is_param_char(char c) {
return
(c != 0) &&
(c != '{') &&
(c != '[') &&
(c != '&') &&
(c != '=');
}
From reading your code, it should also work around the bug, but I can't test it.
Edit: explicitly test c for null (c!=0) instead of (c).
Yes, I also think is best to replace the macro with a function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
@me-no-dev Please review. |
In WebRequest.cpp at line 150:
while (i<len && __is_param_char(((char*)buf)[i++]));
the macro
__is_param_char
will expand producing multiplei++
invocations making the algorithm to (sometimes) fail.