avformat/http: return EINVAL if ff_http_do_new_request is called with non-http URLContext
authorAman Gupta <aman@tmm1.net>
Fri, 29 Dec 2017 23:25:14 +0000 (15:25 -0800)
committerAman Gupta <aman@tmm1.net>
Sat, 30 Dec 2017 17:58:03 +0000 (09:58 -0800)
Signed-off-by: Aman Gupta <aman@tmm1.net>
libavformat/http.c

index a376f1a..8f7e56d 100644 (file)
@@ -311,6 +311,11 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
     char hostname1[1024], hostname2[1024], proto1[10], proto2[10];
     int port1, port2;
 
+    if (!h->prot ||
+        !(!strcmp(h->prot->name, "http") ||
+          !strcmp(h->prot->name, "https")))
+        return AVERROR(EINVAL);
+
     av_url_split(proto1, sizeof(proto1), NULL, 0,
                  hostname1, sizeof(hostname1), &port1,
                  NULL, 0, s->location);