From:             borchinfolab at gmail dot com
Operating system: FC9
PHP version:      5.3CVS-2008-11-27 (snap)
PHP Bug Type:     Reproducible crash
Bug description:  fread for ssh2 streams core dumps for non-blocking channels

Description:
------------
fread() fails (core dumps) for ssh2 streams.

I have checked the libssh2 library by writing a small C program, and it
seems to handle non-blocking channels correct.

The stream read command (libssh2_channel_read_ex) does return -37 for
non-blocking channels where there are no pending bytes. This "error" might
be reason for the core dump? 

Not sure if the correct place to fix this is in the fread() function or
the php_ssh2_channel_stream_read() function by preventing it from returning
a negative number (libssh2).

The ssh2 pecl package does not compile under php 5.3 (I belive this is a
error in the package and not in php-headers - I've managed to fix this
though, so it does compile)


Reproduce code:
---------------
#!/usr/bin/php
<?php

$connection = ssh2_connect(SERVER_NAME, 22, array('hostkey'=>'ssh-rsa'));
if(ssh2_auth_pubkey_file($connection, USERNAME, ID_PUB, ID_RSA, '')) {
   $stream = ssh2_exec($connection, "ps -elf");
   # stream_set_blocking($stream, false); THIS DOSN'T WORK
   stream_set_blocking($stream, true); // THIS WORKS

   while(!feof($stream)) {
      $buf = fread($stream, 1024);
      echo ">$buf\n";
   }
}

?>

Expected result:
----------------
No core dump

Actual result:
--------------
Core dump

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

Reply via email to