[vlc-commits] http: robustify vlc_UrlParse() (fixes #8432)

Rémi Denis-Courmont git at videolan.org
Sun Apr 14 17:07:00 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 14 18:06:24 2013 +0300| [25ab9b02f70c0047905ffef4b0a5bcc5b3137a78] | committer: Rémi Denis-Courmont

http: robustify vlc_UrlParse() (fixes #8432)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=25ab9b02f70c0047905ffef4b0a5bcc5b3137a78
---

 src/text/url.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/text/url.c b/src/text/url.c
index 39fb768..cba463c 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -400,13 +400,16 @@ void vlc_UrlParse (vlc_url_t *restrict url, const char *str, unsigned char opt)
     char *cur = buf, *next;
 
     /* URL scheme */
-    next = strchr (cur, ':');
+    next = buf;
+    while ((*next >= 'A' && *next <= 'Z') || (*next >= 'a' && *next <= 'z')
+        || (*next >= '0' && *next <= '9') || (strchr ("+-.", *next) != NULL))
+        next++;
     /* This is not strictly correct. In principles, the scheme is always
      * present in an absolute URL and followed by a colon. Depending on the
      * URL scheme, the two subsequent slashes are not required.
      * VLC uses a different scheme for historical compatibility reasons - the
      * scheme is often implicit. */
-    if (next != NULL && !strncmp (next + 1, "//", 2))
+    if (*next == ':' && !strncmp (next + 1, "//", 2))
     {
         *next = '\0';
         next += 3;



More information about the vlc-commits mailing list