You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-php/pecl-ssh2/files/0.13-parse_url-fix.patch

50 lines
1.7 KiB

From 093906ec1c065e86ad1cd4dabbc89b1ccae11938 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Thu, 10 Nov 2016 09:16:02 +0100
Subject: [PATCH] fix for PHP 7.0.13 where php_url_parse fails
---
ssh2_fopen_wrappers.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/ssh2_fopen_wrappers.c b/ssh2_fopen_wrappers.c
index 8472ddd..89b34eb 100644
--- a/ssh2_fopen_wrappers.c
+++ b/ssh2_fopen_wrappers.c
@@ -198,10 +198,20 @@ 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);
+ 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;
}
@@ -232,9 +242,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;
--
2.1.4