php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63529
Patch enable_compression_add_new_option revision 2014-08-28 14:01 UTC by phpbugs2012 at joern dot heissler dot de
Patch enable-compression.patch revision 2012-11-15 16:04 UTC by trevor at blubolt dot com

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)) {
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 20 20:01:27 2021 UTC