-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix bug 70470 #2736
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 bug 70470 #2736
Conversation
|
The ext/soap/tests/bug73037.phpt test failure might be legitimate. |
| zend_string_release(orig_header_name); | ||
| switch (client->last_header_element) { | ||
| case VALUE: | ||
| php_cli_server_client_save_header(client); |
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.
/* break missing intentionally */
sapi/cli/php_cli_server.c
Outdated
| if (client->current_header_name_allocated) { | ||
| size_t new_length = client->current_header_name_len + length; | ||
| client->current_header_name = perealloc(client->current_header_name, new_length + 1, 1); | ||
| strncpy(client->current_header_name + client->current_header_name_len, at, length); |
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 think it's safer to use memcpy here and below, to avoid uninitialized memory in case there are null bytes (I have no idea if it can actually happen).
sapi/cli/php_cli_server.c
Outdated
| break; | ||
| case NONE: | ||
| // can't happen | ||
| assert(1); |
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.
Should be assert(0)?
sapi/cli/php_cli_server.c
Outdated
| switch (client->last_header_element) { | ||
| case NONE: | ||
| break; | ||
| case FIELD: |
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.
Can the FIELD case occur here and if so, will it be handled correctly?
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.
Yes it can occur and it needs to be handled appropriately, fixed
sapi/cli/php_cli_server.c
Outdated
| case VALUE: | ||
| php_cli_server_client_save_header(client); | ||
| case NONE: | ||
| client->current_header_name = at; |
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.
This discards a const qualifier, so needs a (char *) cast.
|
The soap failure is legitimate. Valgrind: Line 1583 corresponds to line 1588 in this PR: https://github.com/php/php-src/pull/2736/files#diff-d705e80d519f022dee38ccc6c177a926R1588 |
| client->last_header_element = NONE; | ||
| client->current_header_name = NULL; | ||
| client->current_header_name_len = 0; | ||
| client->current_header_name_allocated = 0; |
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.
This initialization should not be removed. Alternatively or additionally the variable should be initialized in https://github.com/php/php-src/pull/2736/files#diff-d705e80d519f022dee38ccc6c177a926R1636.
sapi/cli/php_cli_server.c
Outdated
| unsigned int current_header_name_allocated:1; | ||
| char *current_header_value; | ||
| size_t current_header_value_len; | ||
| enum { NONE=0, FIELD, VALUE } last_header_element; |
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'd suggest prefixing the enum members, e.g. HEADER_NONE, HEADER_FIELD, HEADER_VALUE.
|
I think I've addressed all your comments adequately, thanks for the thorough review |
|
Merged as cd9d90f into 7.0+. Thanks! |
|
Hrm, looks like a new test failure showed up on AppVeyor: |
|
Valgrind: |
|
Fixed in 42549b7. |
This fixes https://bugs.php.net/bug.php?id=70470 by merging together repeat invocations of on_header_field and on_header_value by appending the strings together into one. After this PR the XFAILing testcase passes
cc @esnunes