gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnurl] 131/222: urlapi: fix URL encoding when setting a full URL


From: gnunet
Subject: [gnurl] 131/222: urlapi: fix URL encoding when setting a full URL
Date: Thu, 07 Nov 2019 00:10:27 +0100

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnurl.

commit 2c20109a9b5d0499a14a0226e68d55d027ecdb20
Author: Daniel Stenberg <address@hidden>
AuthorDate: Tue Oct 1 09:53:28 2019 +0200

    urlapi: fix URL encoding when setting a full URL
---
 lib/urlapi.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/urlapi.c b/lib/urlapi.c
index 1c13077ec..a57c5e72e 100644
--- a/lib/urlapi.c
+++ b/lib/urlapi.c
@@ -851,6 +851,16 @@ static CURLUcode seturl(const char *url, CURLU *u, 
unsigned int flags)
   if(junkscan(path))
     return CURLUE_MALFORMED_INPUT;
 
+  if((flags & CURLU_URLENCODE) && path[0]) {
+    /* worst case output length is 3x the original! */
+    char *newp = malloc(strlen(path) * 3);
+    if(!newp)
+      return CURLUE_OUT_OF_MEMORY;
+    path_alloced = TRUE;
+    strcpy_url(newp, path, TRUE); /* consider it relative */
+    path = newp;
+  }
+
   fragment = strchr(path, '#');
   if(fragment)
     *fragment++ = 0;
@@ -865,11 +875,16 @@ static CURLUcode seturl(const char *url, CURLU *u, 
unsigned int flags)
   else if(!(flags & CURLU_PATH_AS_IS)) {
     /* sanitise paths and remove ../ and ./ sequences according to RFC3986 */
     char *newp = Curl_dedotdotify(path);
-    if(!newp)
+    if(!newp) {
+      if(path_alloced)
+        free(path);
       return CURLUE_OUT_OF_MEMORY;
+    }
 
     if(strcmp(newp, path)) {
       /* if we got a new version */
+      if(path_alloced)
+        free(path);
       path = newp;
       path_alloced = TRUE;
     }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]