Skip to content

php_embed_ub_write does not return on error #23423

Description

@Sjord

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions