]> git.pld-linux.org Git - packages/php-pecl-ssh2.git/blame - bug-73524.patch
fix bug #73524: segfault in scandir over ssh2
[packages/php-pecl-ssh2.git] / bug-73524.patch
CommitLineData
7969f0ad
ER
1From 093906ec1c065e86ad1cd4dabbc89b1ccae11938 Mon Sep 17 00:00:00 2001
2From: Remi Collet <remi@php.net>
3Date: Thu, 10 Nov 2016 09:16:02 +0100
4Subject: [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
10diff --git a/ssh2_fopen_wrappers.c b/ssh2_fopen_wrappers.c
11index 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.098691 seconds and 4 git commands to generate.