php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58713 ssh2_connect() to an invalid port results in mem alloc error
Submitted: 2009-06-09 10:41 UTC Modified: 2012-10-06 09:15 UTC
From: mkliewe at gmx dot de Assigned:
Status: No Feedback Package: ssh2 (PECL)
PHP Version: 5.2.9 OS: Windows 2003
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mkliewe at gmx dot de
New email:
PHP Version: OS:

 

 [2009-06-09 10:41 UTC] mkliewe at gmx dot de
Description:
------------
Connecting to a "wrong" port results in memory allocation error (which cannot be catched and php exits immediately).

If using an unused port like
$ret = ssh2_connect('server234.domain.de', 19);
the command runs into a timeout and returns "false" (and outputs a warning "Unable to connect to server234.domain.de on port 19 in..." which is OK.

If using the port 21 (where a ftp service listens)
$ret = ssh2_connect('server234.domain.de', 21);
I get an error:
Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 892678102 bytes) in D:\testSFTP.php on line 2
(see reproduceable code below)

If using the port 80 (where an apache webserver listens)
$ret = ssh2_connect('server234.domain.de', 80);
then the php process goes to 100% cpu and I have to kill it.

The last two examples should instead return "false" and output a warning.



I'm using
PECL 5.2.6 Win32 binaries
PHP 5.2.9-1 (cli) (built: Mar  5 2009 20:02:28)

Reproduce code:
---------------
<?php
$ret = ssh2_connect('server234.domain.de', 21);
var_dump($ret);

Expected result:
----------------
output should be "false" plus a warning

Actual result:
--------------
Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 892678102 bytes) in D:\testSFTP.php on line 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-23 10:44 UTC] langemeijer@php.net
-Status: Open +Status: Feedback
 [2012-06-23 10:44 UTC] langemeijer@php.net
Cannot reproduce this, using the latest versions of libssh2 and ssh2 extension on 
linux.

Could you see if the problem still exists?
 [2012-10-06 09:15 UTC] langemeijer@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2012-10-06 09:15 UTC] langemeijer@php.net
-Status: Feedback +Status: No Feedback
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 19 19:01:23 2021 UTC