php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58843 ssh2 pecl package portability on Windows
Submitted: 2009-08-31 09:29 UTC Modified: 2012-06-14 22:03 UTC
From: pkleef at openlinksw dot com Assigned: langemeijer (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.2.10 OS: Windows
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: pkleef at openlinksw dot com
New email:
PHP Version: OS:

 

 [2009-08-31 09:29 UTC] pkleef at openlinksw dot com
Description:
------------
We tried to compile this excellent pecl extension on Windows 
and we found a portability issue in the network code. 

The extension uses plain "close(socket)" function instead of 
"closesocket(socket)". There is no problem using closesocket 
on Unix, since PHP provides a define for this, which is used 
throughout PHP itself as well. 

I have attached a small patch for your consideration.

Reproduce code:
---------------
* rename close -> closesocket so it will work on Windows
diff -up ssh2-0.11.0/ssh2.c.orig ssh2-0.11.0/ssh2.c
--- ssh2-0.11.0/ssh2.c.orig     2008-12-02 21:50:10.000000000 +0100
+++ ssh2-0.11.0/ssh2.c  2009-08-31 10:23:27.000000000 +0200
@@ -358,7 +358,7 @@ LIBSSH2_SESSION *php_ssh2_session_connec
        if (!session) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to initialize SSH2 session");
                efree(data);
-               close(socket);
+               closesocket(socket);
                return NULL;
        }
        libssh2_banner_set(session, LIBSSH2_SSH_DEFAULT_BANNER " PHP");
@@ -434,7 +434,7 @@ LIBSSH2_SESSION *php_ssh2_session_connec

                last_error = libssh2_session_last_error(session, &error_msg, NULL, 0);
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error starting up SSH connection(%d): %s", last_error, error_msg);
-               close(socket);
+               closesocket(socket);
                libssh2_session_free(session);
                efree(data);
                return NULL;
@@ -1148,7 +1148,7 @@ static void php_ssh2_session_dtor(zend_r
                        zval_ptr_dtor(&(*data)->disconnect_cb);
                }

-               close((*data)->socket);
+               closesocket((*data)->socket);

                efree(*data);
                *data = NULL;



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-14 22:03 UTC] langemeijer@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: langemeijer
 [2012-06-14 22:03 UTC] langemeijer@php.net
Exactly this patch seemed to have made it to SVN on 2/8/2009 already.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 01:01:27 2020 UTC