[FFmpeg-cvslog] lavf/http: Properly process HTTP header on listen.
Stephan Holljes
git at videolan.org
Sat Jun 6 12:51:41 CEST 2015
ffmpeg | branch: master | Stephan Holljes <klaxa1337 at googlemail.com> | Thu Jun 4 01:21:02 2015 +0200| [a7e7c68b0e264f5db15bbbf9fb3cd557cc58e927] | committer: Nicolas George
lavf/http: Properly process HTTP header on listen.
Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a7e7c68b0e264f5db15bbbf9fb3cd557cc58e927
---
libavformat/http.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/libavformat/http.c b/libavformat/http.c
index a5b3e29..53bdb98 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -563,7 +563,7 @@ static int process_line(URLContext *h, char *line, int line_count,
int *new_location)
{
HTTPContext *s = h->priv_data;
- char *tag, *p, *end;
+ char *tag, *p, *end, *method, *resource, *version;
int ret;
/* end of header */
@@ -574,6 +574,44 @@ static int process_line(URLContext *h, char *line, int line_count,
p = line;
if (line_count == 0) {
+ if (s->listen) {
+ // HTTP method
+ method = p;
+ while (!av_isspace(*p))
+ p++;
+ *(p++) = '\0';
+ av_log(h, AV_LOG_TRACE, "Received method: %s\n", method);
+ if (s->method) {
+ if (av_strcasecmp(s->method, method)) {
+ av_log(h, AV_LOG_ERROR, "Received and expected HTTP method do not match. (%s expected, %s received)\n",
+ s->method, method);
+ return ff_http_averror(400, AVERROR(EIO));
+ }
+ }
+
+ // HTTP resource
+ while (av_isspace(*p))
+ p++;
+ resource = p;
+ while (!av_isspace(*p))
+ p++;
+ *(p++) = '\0';
+ av_log(h, AV_LOG_TRACE, "Requested resource: %s\n", resource);
+
+ // HTTP version
+ while (av_isspace(*p))
+ p++;
+ version = p;
+ while (!av_isspace(*p))
+ p++;
+ *p = '\0';
+ if (av_strncasecmp(version, "HTTP/", 5)) {
+ av_log(h, AV_LOG_ERROR, "Malformed HTTP version string.\n");
+ return ff_http_averror(400, AVERROR(EIO));
+ }
+ av_log(h, AV_LOG_TRACE, "HTTP version string: %s\n", version);
+ } else {
+ /* TODO: reindent */
while (!av_isspace(*p) && *p != '\0')
p++;
while (av_isspace(*p))
@@ -584,6 +622,7 @@ static int process_line(URLContext *h, char *line, int line_count,
if ((ret = check_http_code(h, s->http_code, end)) < 0)
return ret;
+ }
} else {
while (*p != '\0' && *p != ':')
p++;
More information about the ffmpeg-cvslog
mailing list