Patch enable_compression_add_new_option for ssh2 Bug #63529
Patch version 2014-08-28 14:01 UTC
Return to Bug #63529 |
Download this patch
Patch Revisions:
Developer: phpbugs2012@joern.heissler.de
diff --git a/ssh2.c b/ssh2.c
index f232c41..268890b 100644
--- a/ssh2.c
+++ b/ssh2.c
@@ -321,6 +321,25 @@ static int php_ssh2_set_method(LIBSSH2_SESSION *session, HashTable *ht, char *me
}
/* }}} */
+/* {{{ php_ssh2_set_flag
+ * Try to set a session flag if it's passed in with the hash table
+ */
+static int php_ssh2_set_flag(LIBSSH2_SESSION *session, HashTable *ht, char *flag, int flag_len, int flag_type)
+{
+ zval **value;
+
+ if (zend_hash_find(ht, flag, flag_len + 1, (void**)&value) == FAILURE) {
+ return 0;
+ }
+
+ if (!value || !*value || (Z_TYPE_PP(value) != IS_BOOL)) {
+ return -1;
+ }
+
+ return libssh2_session_flag(session, flag_type, (int)Z_BVAL_PP(value));
+}
+/* }}} */
+
/* {{{ php_ssh2_session_connect
* Connect to an SSH server with requested methods
*/
@@ -371,6 +390,12 @@ LIBSSH2_SESSION *php_ssh2_session_connect(char *host, int port, zval *methods, z
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed overriding HOSTKEY method");
}
+ #ifdef LIBSSH2_FLAG_COMPRESS
+ if (php_ssh2_set_flag(session, HASH_OF(methods), "enable_compression", sizeof("enable_compression") - 1, LIBSSH2_FLAG_COMPRESS)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed setting COMPRESS flag");
+ }
+ #endif
+
if (zend_hash_find(HASH_OF(methods), "client_to_server", sizeof("client_to_server"), (void**)&container) == SUCCESS &&
container && *container && Z_TYPE_PP(container) == IS_ARRAY) {
if (php_ssh2_set_method(session, HASH_OF(*container), "crypt", sizeof("crypt") - 1, LIBSSH2_METHOD_CRYPT_CS)) {
|