]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
header_callback: strip off file path separated with backslashes
authorDaniel Stenberg <daniel@haxx.se>
Thu, 16 Sep 2010 21:11:48 +0000 (23:11 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 12 Oct 2010 20:56:21 +0000 (22:56 +0200)
If the filename contains a backslash, only use filename portion. The
idea is that even systems that don't handle backslashes as path
separators probably want that path removed for convenience.

This flaw is considered a security problem, see the curl security
vulnerability http://curl.haxx.se/docs/adv_20101013.html

src/main.c

index 8572328cda4322e5e813c3c179dbe6491153a534..95b47ea3a27e5ee87ee8130eccc9ff95ff66f34e 100644 (file)
@@ -4368,6 +4368,18 @@ parse_filename(char *ptr, size_t len)
     }
   }
 
+  /* If the filename contains a backslash, only use filename portion. The idea
+     is that even systems that don't handle backslashes as path separators
+     probably want the path removed for convenience. */
+  q = strrchr(p, '\\');
+  if (q) {
+    p = q+1;
+    if (!*p) {
+      free(copy);
+      return NULL;
+    }
+  }
+
   if(quote) {
     /* if the file name started with a quote, then scan for the end quote and
        stop there */