diff mbox

[FFmpeg-devel,1/2] avformat/http: return EINVAL if ff_http_do_new_request is called with non-http URLContext

Message ID 20171229234158.33456-1-ffmpeg@tmm1.net
State Accepted
Commit c0b08ef94f037572876448990dca840b85432262
Headers show

Commit Message

Aman Karmani Dec. 29, 2017, 11:41 p.m. UTC
From: Aman Gupta <aman@tmm1.net>

Signed-off-by: Aman Gupta <aman@tmm1.net>
---
 libavformat/http.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Carl Eugen Hoyos Dec. 30, 2017, 6:04 p.m. UTC | #1
2017-12-30 0:41 GMT+01:00 Aman Gupta <ffmpeg@tmm1.net>:

> +    if (!h->prot ||
> +        !(!strcmp(h->prot->name, "http") ||
> +          !strcmp(h->prot->name, "https")))

Can't this be simplified?

Carl Eugen
wm4 Dec. 30, 2017, 6:11 p.m. UTC | #2
On Fri, 29 Dec 2017 15:41:57 -0800
Aman Gupta <ffmpeg@tmm1.net> wrote:

> From: Aman Gupta <aman@tmm1.net>
> 
> Signed-off-by: Aman Gupta <aman@tmm1.net>
> ---
>  libavformat/http.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index a376f1a488..8f7e56de54 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -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);

I rejected this, why was it pushed?
Aman Karmani Dec. 30, 2017, 6:21 p.m. UTC | #3
On Sat, Dec 30, 2017 at 10:11 AM wm4 <nfxjfg@googlemail.com> wrote:

> On Fri, 29 Dec 2017 15:41:57 -0800
> Aman Gupta <ffmpeg@tmm1.net> wrote:
>
> > From: Aman Gupta <aman@tmm1.net>
> >
> > Signed-off-by: Aman Gupta <aman@tmm1.net>
> > ---
> >  libavformat/http.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/libavformat/http.c b/libavformat/http.c
> > index a376f1a488..8f7e56de54 100644
> > --- a/libavformat/http.c
> > +++ b/libavformat/http.c
> > @@ -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);
>
> I rejected this, why was it pushed?


Sorry, I understood the rejection to be about the second patch in the set,
which is a hack to avoid crypto-wrapped segments.

This patch enforces that ff_http_do_new_request() is only invoked on
http/https URLContext, which seemed like a sane safe-guard to me.

Aman


> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/libavformat/http.c b/libavformat/http.c
index a376f1a488..8f7e56de54 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -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);