php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #69981
Patch ssh2_getpath revision 2019-03-20 20:01 UTC by ken at pardiac dot com
Patch ssh2_findpath revision 2019-03-20 19:48 UTC by ken at pardiac dot om
Patch ssh2_sftp_pathfix revision 2015-11-06 17:10 UTC by ken at pardiac dot com

Patch ssh2_sftp_pathfix for ssh2 Bug #69981

Patch version 2015-11-06 17:10 UTC

Return to Bug #69981 | Download this patch
Patch Revisions:

Developer: ken@pardiac.com

--- ssh2_fopen_wrappers.c	2012-10-02 16:18:07.000000000 -0400
+++ ssh2_fopen_wrappers.c	2015-11-06 11:20:40.436490279 -0500
@@ -219,12 +219,29 @@
 	}
 
 	/*
-		Find resource->path in the path string, then copy the entire string from the original path.
-		This includes ?query#fragment in the path string
+		Put path, query and fragment from the url back together to get a filename
+		that may have contained ? or #.
 	*/
-	s = resource->path;
-	resource->path = estrdup(strstr(path, resource->path));
-	efree(s);
+	if ( resource->query || resource->fragment ) {
+		char *p;
+		int len = strlen(resource->path) + 1;
+		if ( resource->query )
+			len +=  strlen(resource->query) + 1;
+		if ( resource->fragment )
+			len += strlen(resource->fragment) + 1;
+		p = emalloc( len );
+		strcpy( p, resource->path );
+		if ( resource->query ) {
+			strcat( p, "?" );
+			strcat( p, resource->query );
+		}
+		if ( resource->fragment ) {
+			strcat( p, "#" );
+			strcat( p, resource->fragment );
+		}
+		efree( resource->path );
+		resource->path = p;
+	}
 
 	/* Look for a resource ID to reuse a session */
 	s = resource->host;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC