From 864f17d894d0e4d2d790613d42ca5c89aad5bb05 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 6 Dec 2014 20:46:54 +0000 Subject: smb: Fixed URL encoded URLs not working --- lib/smb.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'lib/smb.c') diff --git a/lib/smb.c b/lib/smb.c index 07a5c642b..b75b1b333 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -42,6 +42,7 @@ #include "vtls/vtls.h" #include "curl_ntlm_core.h" #include "curl_memory.h" +#include "escape.h" /* The last #include file should be: */ #include "memdebug.h" @@ -175,6 +176,7 @@ struct smb_request { static CURLcode smb_setup(struct connectdata *conn) { + CURLcode result = CURLE_OK; struct smb_request *req; char *slash; char *path; @@ -187,18 +189,29 @@ static CURLcode smb_setup(struct connectdata *conn) req->state = SMB_REQUESTING; req->result = CURLE_OK; + /* URL decode the path */ + result = Curl_urldecode(conn->data, conn->data->state.path, 0, &path, NULL, + TRUE); + if(result) + return result; + /* Parse the share and path */ - path = conn->data->state.path; req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path); - if(!req->share) + if(!req->share) { + Curl_safefree(path); + return CURLE_OUT_OF_MEMORY; + } slash = strchr(req->share, '/'); if(!slash) slash = strchr(req->share, '\\'); - if(!slash) + if(!slash) { + Curl_safefree(path); + return CURLE_URL_MALFORMAT; + } *slash++ = 0; req->path = slash; @@ -207,6 +220,8 @@ static CURLcode smb_setup(struct connectdata *conn) *slash = '\\'; } + Curl_safefree(path); + return CURLE_OK; } -- cgit v1.2.3