Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-02-13 14:47:49 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2017-02-14 06:02:51 +0300
commit8fa18e042ad2c078f759692f1db5629d16d70595 (patch)
treef0a5b84c4bad1e78766d058b6bc604a8b08c9222 /libavformat
parent1c049d5ffe08b3af36844cdbe7a5950879122b8b (diff)
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>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/http.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index 944a6cf322..bd1be3f7bb 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1011,6 +1011,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;
@@ -1107,7 +1108,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"
@@ -1123,6 +1124,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;