php_embed_ub_write does not return on error
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in sapi/embed/php_embed.c at php_embed_ub_write and trace the php_embed_single_write error path followed by php_handle_aborted_connection. Verify that a zero-byte write cannot repeat indefinitely when the connection is not aborted. Done means the function returns the number of bytes written after the error instead of looping forever.
Written by the indexing model from the issue text.
Description
Description
sapi/embed/php_embed.c:
/* SAPIs only have unbuffered write operations. This is because PHP's output
* buffering feature will handle any buffering of the output and invoke the
* SAPI unbuffered write operation when it flushes the buffer.
*/
static size_t php_embed_ub_write(const char *str, size_t str_length)
{
const char *ptr = str;
size_t remaining = str_length;
size_t ret;
while (remaining > 0) {
ret = php_embed_single_write(ptr, remaining);
if (!ret) {
php_handle_aborted_connection();
}
ptr += ret;
remaining -= ret;
}
return str_length;
}
php_handle_aborted_connection does not always abort, i.e. if ignore_user_abort=1. So I sending fails and ret is 0, then remaining is never decremented and this loops forever.
It should probably return str_length - remaining after php_handle_aborted_connection().
PHP Version
master
Operating System
No response
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 112
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from php/php-src
-
Bug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Bug Status: Needs Triage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Bug Category: Tests Status: Verified
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Bug SAPI: fpm Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Bug Extension: openssl Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Similar issues
-
Status: Waiting triage Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nanoframework/Home#1857 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
libsdl-org/SDL#16372 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
corazawaf/coraza-nginx#140 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100