php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74159 writing a large buffer to non-blocking encrypted streams fails
Submitted: 2017-02-24 00:37 UTC Modified: 2017-03-14 18:26 UTC
From: daverandom@php.net Assigned: bukka (profile)
Status: Duplicate Package: OpenSSL related
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
 [2017-02-24 00:37 UTC] daverandom@php.net
Description:
------------
Attempting to write a large buffer to a non-blocking encrypted stream will fail, as SSL_write() expects to be passed the *exact* same buffer (same ptr addr) for successive calls.

Test script:
---------------
<?php

$fp = stream_socket_client("tcp://lxr.room11.org:443");
stream_set_blocking($fp, false);
while (!stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_ANY_CLIENT));
var_dump(fwrite($fp, "POST / HTTP/1.1\r\nHost: lxr.room11.org\r\nContent-Type: text/plain\r\nContent-Length: 131072\r\n\r\n"));
$data = str_repeat("a", 65536);
var_dump(fwrite($fp, $data));
var_dump(fwrite($fp, $data));
var_dump(fwrite($fp, $data));

Expected result:
----------------
No errors

Actual result:
--------------
error:1409F07F:SSL routines:ssl3_write_pending:bad write retry

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-24 01:28 UTC] trowski@php.net
-Assigned To: +Assigned To: trowski
 [2017-02-24 03:00 UTC] trowski@php.net
Automatic comment on behalf of aaron@trowski.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e9873d9853da2b6153776c2e5ed6858e87f0baa2
Log: Fix bug #74159
 [2017-02-24 03:00 UTC] trowski@php.net
-Status: Assigned +Status: Closed
 [2017-02-24 03:22 UTC] trowski@php.net
Automatic comment on behalf of aaron@trowski.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e9873d9853da2b6153776c2e5ed6858e87f0baa2
Log: Fix bug #74159
 [2017-02-24 03:23 UTC] trowski@php.net
Automatic comment on behalf of aaron@trowski.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e9873d9853da2b6153776c2e5ed6858e87f0baa2
Log: Fix bug #74159
 [2017-03-02 19:42 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=511a4b0918bc6a70b706cc3ed90e03daa0852c02
Log: Revert &quot;Fix bug #74159&quot;
 [2017-03-03 06:29 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d03d7ee6b8b67bafc4bd7d399f450db138d9acae
Log: Revert &quot;Fix bug #74159&quot;
 [2017-03-14 18:26 UTC] bukka@php.net
-Status: Closed +Status: Duplicate -Assigned To: trowski +Assigned To: bukka
 [2017-03-14 18:26 UTC] bukka@php.net
This is actually a duplicate of https://bugs.php.net/bug.php?id=72333 . I also reassigned to myself to get notification as #72333 fixes that.

I kept the test as it tests some other possible cases. However the test actually doesn't fail reliably without the fix as it doesn't have big enough delay to accumulate enough data in the kernel network stack (that's my guess but it was passing for me without the fix so there is something wrong). Anyway I kept it as it might fail on some slower machines (without the fix) so it's kind of related.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC