|  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:
Bug Type:
From: mkliewe at gmx dot de
New email:
PHP Version: OS:


 [2009-06-09 10:41 UTC] mkliewe at gmx dot de
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('', 19);
the command runs into a timeout and returns "false" (and outputs a warning "Unable to connect to on port 19 in..." which is OK.

If using the port 21 (where a ftp service listens)
$ret = ssh2_connect('', 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('', 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:
$ret = ssh2_connect('', 21);

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


Add a Patch

Pull Requests

Add a Pull Request


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

Could you see if the problem still exists?
 [2012-10-06 09:15 UTC]
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]
-Status: Feedback +Status: No Feedback
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Oct 02 23:05:52 2022 UTC