rtmp: Fix a possible access to invalid memory location when the playpath is too short.
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 11 Jun 2012 12:21:32 +0000 (14:21 +0200)
committerMartin Storsjö <martin@martin.st>
Tue, 12 Jun 2012 11:33:57 +0000 (14:33 +0300)
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtmpproto.c

index e9a3e43..56011f1 100644 (file)
@@ -1141,11 +1141,11 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
             goto fail;
         }
 
-        if (!strchr(fname, ':') &&
+        if (!strchr(fname, ':') && len >= 4 &&
             (!strcmp(fname + len - 4, ".f4v") ||
              !strcmp(fname + len - 4, ".mp4"))) {
             memcpy(rt->playpath, "mp4:", 5);
-        } else if (!strcmp(fname + len - 4, ".flv")) {
+        } else if (len >= 4 && !strcmp(fname + len - 4, ".flv")) {
             fname[len - 4] = '\0';
         } else {
             rt->playpath[0] = 0;