diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-02-13 12:47:49 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-05-16 16:00:21 +0200 |
commit | 3364c8c53a4b49dfc9b7a075d88f688e52c3c453 (patch) | |
tree | 10b4e804b3ac2c5a1cf6e98b99e4f531dc49a29c | |
parent | 5cd2fcd0a72334d4b3beb32247df3ebd93a7ded9 (diff) | |
download | ffmpeg-3364c8c53a4b49dfc9b7a075d88f688e52c3c453.tar.gz |
avformat/http: Check for truncated buffers in http_connect()
Reported-by: SleepProgger <security@gnutp.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8fa18e042ad2c078f759692f1db5629d16d70595)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/http.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libavformat/http.c b/libavformat/http.c index 7e109ddb5b..c5d94038e3 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1002,6 +1002,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, int len = 0; const char *method; int send_expect_100 = 0; + int ret; /* send http header */ post = h->flags & AVIO_FLAG_WRITE; @@ -1092,7 +1093,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, if (s->headers) av_strlcpy(headers + len, s->headers, sizeof(headers) - len); - snprintf(s->buffer, sizeof(s->buffer), + ret = snprintf(s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" "%s" "%s" @@ -1108,6 +1109,14 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, av_log(h, AV_LOG_DEBUG, "request: %s\n", s->buffer); + if (strlen(headers) + 1 == sizeof(headers) || + ret >= sizeof(s->buffer)) { + av_log(h, AV_LOG_ERROR, "overlong headers\n"); + err = AVERROR(EINVAL); + goto done; + } + + if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) goto done; |