|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57768 Segmentation fault on a stream without resource id
Submitted: 2007-08-03 12:28 UTC Modified: 2009-01-10 15:01 UTC
From: Assigned:
Status: Closed Package: ssh2 (PECL)
PHP Version: Irrelevant OS: linux
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:
New email:
PHP Version: OS:


 [2007-08-03 12:28 UTC]
The following code ends up in a segmentation fault


I am not sure if this is "right", but the following 3 lines of code fixed this problem for me

--- /tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c     2007-08-03 17:35:34.000000000 +0200
+++ ssh2_fopen_wrappers.c       2007-08-03 18:16:06.000000000 +0200
@@ -124,6 +124,10 @@
        resource = php_url_parse(path);
+        if (!resource) {
+                return NULL; 
+        }
        if (strncmp(resource->scheme, "ssh2.", sizeof("ssh2.") - 1)) {
                /* Not an ssh wrapper */

Reproduce code:

Expected result:

Actual result:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1216297296 (LWP 1257)]
0xb566ae9c in php_ssh2_fopen_wraper_parse_path (path=0x8ef3ba8 "ssh2.sftp:///home/apache", type=0xb566e628 "sftp", context=0x0, psession=0xbfe03a08, 
    presource_id=0xbfe03a00, psftp=0xbfe03a04, psftp_rsrcid=0xbfe039fc) at /home/u80759076/Projekte/ssh2/ssh2-0.10/ssh2_fopen_wrappers.c:129
129             if (strncmp(resource->scheme, "ssh2.", sizeof("ssh2.") - 1)) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-08 18:57 UTC] smclean at gmail dot com
Just wanted to say, I just ran in to this bug too.  I couldn't figure it out at all until I ran php in gdb and went source diving.  Some validation of 'resource' would definitely be nice!
 [2009-01-10 15:01 UTC]
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 07:01:30 2024 UTC