php / php/php-src

php_embed_ub_write does not return on error

オープン 初心者向け
#23,423 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 15時間
マージ済み PR(30日)
103

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

sapi/embed/php_embed.c の php_embed_ub_write から開始し、php_embed_single_write のエラーパス、続いて php_handle_aborted_connection を追跡します。接続が中断されていない場合に、ゼロバイトの書き込みが無限に繰り返されないことを確認します。完了条件は、関数が無限ループする代わりに、エラー後に書き込まれたバイト数を返すことです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c
領域
backend
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
78/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。