]> git.sesse.net Git - ffmpeg/commitdiff
http: fix potentially dangerous whitespace skipping code
authorwm4 <nfxjfg@googlemail.com>
Thu, 8 Mar 2018 03:52:36 +0000 (04:52 +0100)
committerwm4 <nfxjfg@googlemail.com>
Sun, 18 Mar 2018 11:36:24 +0000 (12:36 +0100)
If the string consists entirely of whitespace, this could in theory
continue to write '\0' before the start of the memory allocation. In
practice, it didn't really happen: the generic HTTP header parsing code
already skips leading whitespaces, so the string is either empty, or
consists a non-whitespace. (The generic code and the cookie code
actually have different ideas about what bytes are whitespace: the
former uses av_isspace(), the latter uses WHITESPACES. Fortunately,
av_isspace() is a super set of the http.c specific WHITESPACES, so
there's probably no case where the above assumption could have been
broken.)

libavformat/http.c

index 59f90ac603469b2b9884294b81b5a4b3e168026a..983034f0830f9832924e56326f4c4516755b654b 100644 (file)
@@ -760,6 +760,8 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
     back = &cstr[strlen(cstr)-1];
     while (strchr(WHITESPACES, *back)) {
         *back='\0';
+        if (back == cstr)
+            break;
         back--;
     }