Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-updates-src > by-pkgid > 751e8574c653d9072c25733fad35bfa9 > files > 1

php-ssh2-0.12-9.1.mga5.src.rpm

--- ssh2_fopen_wrappers.c
+++ ssh2_fopen_wrappers.c	2017-11-14 23:38:03.693309741 +0100
@@ -194,11 +194,22 @@
 	php_url *resource;
 	zval *methods = NULL, *callbacks = NULL, zsession, **tmpzval;
 	long resource_id;
-	char *s, *username = NULL, *password = NULL, *pubkey_file = NULL, *privkey_file = NULL;
+	char *h, *s, *username = NULL, *password = NULL, *pubkey_file = NULL, *privkey_file = NULL;
 	int username_len = 0, password_len = 0;
 
 	resource = php_url_parse(path);
-	if (!resource) {
+	h = strstr(path, "Resource id #");
+	if (h) {
+		/* Starting with 5.6.28, 7.0.13 need to be clean, else php_url_parse will fail */
+		char *tmp = estrdup(path);
+
+		strncpy(tmp + (h-path), h + sizeof("Resource id #")-1, strlen(tmp)-sizeof("Resource id #"));
+		resource = php_url_parse(tmp);
+		efree(tmp);
+	} else {
+		resource = php_url_parse(path);
+	}
+	if (!resource||!resource->path) {
 		return NULL;
 	}
 
@@ -228,9 +239,6 @@
 
 	/* Look for a resource ID to reuse a session */
 	s = resource->host;
-	if (strncmp(resource->host, "Resource id #", sizeof("Resource id #") - 1) == 0) {
-		s = resource->host + sizeof("Resource id #") - 1;
-	}
 	if (is_numeric_string(s, strlen(s), &resource_id, NULL, 0) == IS_LONG) {
 		php_ssh2_sftp_data *sftp_data;