1 From 093906ec1c065e86ad1cd4dabbc89b1ccae11938 Mon Sep 17 00:00:00 2001
2 From: Remi Collet <remi@php.net>
3 Date: Thu, 10 Nov 2016 09:16:02 +0100
4 Subject: [PATCH] fix for PHP 7.0.13 where php_url_parse fails
7 ssh2_fopen_wrappers.c | 17 ++++++++++++-----
8 1 file changed, 12 insertions(+), 5 deletions(-)
10 diff --git a/ssh2_fopen_wrappers.c b/ssh2_fopen_wrappers.c
11 index 8472ddd..89b34eb 100644
12 --- a/ssh2_fopen_wrappers.c
13 +++ b/ssh2_fopen_wrappers.c
14 @@ -198,10 +198,20 @@ php_url *php_ssh2_fopen_wraper_parse_path( char *path, char *type, php_stream_co
16 zval *methods = NULL, *callbacks = NULL, zsession, **tmpzval;
18 - char *s, *username = NULL, *password = NULL, *pubkey_file = NULL, *privkey_file = NULL;
19 + char *h, *s, *username = NULL, *password = NULL, *pubkey_file = NULL, *privkey_file = NULL;
20 int username_len = 0, password_len = 0;
22 - resource = php_url_parse(path);
23 + h = strstr(path, "Resource id #");
25 + /* Starting with 5.6.28, 7.0.13 need to be clean, else php_url_parse will fail */
26 + char *tmp = estrdup(path);
28 + strncpy(tmp + (h-path), h + sizeof("Resource id #")-1, strlen(tmp)-sizeof("Resource id #"));
29 + resource = php_url_parse(tmp);
32 + resource = php_url_parse(path);
34 if (!resource || !resource->path) {
37 @@ -232,9 +242,6 @@ php_url *php_ssh2_fopen_wraper_parse_path( char *path, char *type, php_stream_co
39 /* Look for a resource ID to reuse a session */
41 - if (strncmp(resource->host, "Resource id #", sizeof("Resource id #") - 1) == 0) {
42 - s = resource->host + sizeof("Resource id #") - 1;
44 if (is_numeric_string(s, strlen(s), &resource_id, NULL, 0) == IS_LONG) {
45 php_ssh2_sftp_data *sftp_data;