]> git.sesse.net Git - ffmpeg/commitdiff
http: avoid out of bound accesses on broken Set-Cookie headers
authorwm4 <nfxjfg@googlemail.com>
Thu, 8 Mar 2018 03:47:40 +0000 (04:47 +0100)
committerwm4 <nfxjfg@googlemail.com>
Sun, 18 Mar 2018 11:36:24 +0000 (12:36 +0100)
It's trivial to craft a HTTP response that will make the code for
skipping trailing whitespace access and possibly overwrite bytes outside
of the memory allocation. Why this can happen is blindingly obvious: it
accesses cstr[strlen(cstr)-1] without checking whether the string is
empty.

libavformat/http.c

index d7a72e7129728798fa7b91074e88aceaf7af1429..59f90ac603469b2b9884294b81b5a4b3e168026a 100644 (file)
@@ -750,6 +750,9 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
 {
     char *param, *next_param, *cstr, *back;
 
+    if (!set_cookie[0])
+        return 0;
+
     if (!(cstr = av_strdup(set_cookie)))
         return AVERROR(EINVAL);