File: 0003-fix-for-PHP-7.0.13-where-php_url_parse-fails.patch

package info (click to toggle)
php-ssh2 0.12-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 304 kB
  • ctags: 267
  • sloc: ansic: 2,796; xml: 170; sh: 26; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From: Remi Collet <remi@php.net>
Date: Sat, 1 Dec 2012 15:34:46 +0000
Subject: fix for PHP 7.0.13 where php_url_parse fails

---
 ssh2-0.12/ssh2_fopen_wrappers.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/ssh2-0.12/ssh2_fopen_wrappers.c b/ssh2-0.12/ssh2_fopen_wrappers.c
index 8ba541d..0b47d75 100644
--- a/ssh2-0.12/ssh2_fopen_wrappers.c
+++ b/ssh2-0.12/ssh2_fopen_wrappers.c
@@ -194,11 +194,21 @@ php_url *php_ssh2_fopen_wraper_parse_path(	char *path, char *type, php_stream_co
 	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 +238,6 @@ php_url *php_ssh2_fopen_wraper_parse_path(	char *path, char *type, php_stream_co
 
 	/* 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;