From:             nj506 at zepler dot net
Operating system: Linux
PHP version:      5.3.1
PHP Bug Type:     Streams related
Bug description:  stream_socket_enable_crypto() hangs for unnegotiable SSL 
connections for socket

Description:
------------
stream_socket_enable_crypto() hangs for unnegotiable SSL connections for
sockets connected in asynchronous mode.

Whilst I'm not greatly familiar with the PHP source, I believe it is
caused by the following line of code in xp_ssl.c:

timeout -= (tve.tv_sec + (float) tve.tv_usec / 1000000) - (tvs.tv_sec +
(float) tvs.tv_usec / 1000000);

I'm often seeing no difference in tve.tv_sec and tvs.tv_sec, and the
difference between tve.tv_usec and tvs.tv_usec is typically 4/5
microseconds for the particular scenario I've been debugging. 4/1000000
deduction from the timeout float results in essentially no change.
Therefore the code loops for a very long time. In anycase, a printf on the
timeout float see's no change after running for a good length of time.

Note: I don't believe this is the same issue as #45808, since this affects
client connections, not server connections [+ the area of code I believe to
be guilty is specific to client connections]

I'd also note that stream_set_blocking appears to have no effect on this
area of code - but I'm not sure if thats a bug or not.

Reproduce code:
---------------
<?PHP

// The given address should not be connectable..

$socket = stream_socket_client("tcp://{$address}", $errno, $errstr, 15,
STREAM_CLIENT_CONNECT|STREAM_CLIENT_ASYNC_CONNECT);
var_dump(stream_socket_enable_crypto($socket, true,
STREAM_CRYPTO_METHOD_SSLv23_CLIENT));

?>

Expected result:
----------------
0/false [after "timeout" seconds]

Actual result:
--------------
Hangs pretty much forever.

-- 
Edit bug report at http://bugs.php.net/?id=50866&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50866&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50866&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50866&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50866&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50866&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50866&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50866&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50866&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50866&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50866&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50866&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50866&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50866&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50866&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50866&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50866&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50866&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50866&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50866&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50866&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50866&r=mysqlcfg

Reply via email to