]> git.pld-linux.org Git - packages/php-pecl-ssh2.git/blob - bug-73524.patch
91c91751e5987ebb565b23e03ebee851b68a2abb
[packages/php-pecl-ssh2.git] / bug-73524.patch
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
5
6 ---
7  ssh2_fopen_wrappers.c | 17 ++++++++++++-----
8  1 file changed, 12 insertions(+), 5 deletions(-)
9
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
15         php_url *resource;
16         zval *methods = NULL, *callbacks = NULL, zsession, **tmpzval;
17         long resource_id;
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;
21  
22 -       resource = php_url_parse(path);
23 +       h = strstr(path, "Resource id #");
24 +       if (h) {
25 +               /* Starting with 5.6.28, 7.0.13 need to be clean, else php_url_parse will fail */
26 +               char *tmp = estrdup(path);
27 +
28 +               strncpy(tmp + (h-path), h + sizeof("Resource id #")-1, strlen(tmp)-sizeof("Resource id #"));
29 +               resource = php_url_parse(tmp);
30 +               efree(tmp);
31 +       } else {
32 +               resource = php_url_parse(path);
33 +       }
34         if (!resource || !resource->path) {
35                 return NULL;
36         }
37 @@ -232,9 +242,6 @@ php_url *php_ssh2_fopen_wraper_parse_path(  char *path, char *type, php_stream_co
38  
39         /* Look for a resource ID to reuse a session */
40         s = resource->host;
41 -       if (strncmp(resource->host, "Resource id #", sizeof("Resource id #") - 1) == 0) {
42 -               s = resource->host + sizeof("Resource id #") - 1;
43 -       }
44         if (is_numeric_string(s, strlen(s), &resource_id, NULL, 0) == IS_LONG) {
45                 php_ssh2_sftp_data *sftp_data;
46  
This page took 0.054199 seconds and 2 git commands to generate.