1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avformat/http: return EINVAL from ff_http_do_new_request() if re-used with different hostname

This will prevent improper use of ff_http_do_new_request() if the user
tries to send a request for a different host to a previously connected
persistent http/1.1 connection.

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Karthick J <kjeyapal@akamai.com>
This commit is contained in:
Aman Gupta 2017-12-12 15:50:44 -08:00
parent d2a2bc9a9f
commit 28358e466d

View File

@ -306,6 +306,22 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
HTTPContext *s = h->priv_data;
AVDictionary *options = NULL;
int ret;
char hostname1[1024], hostname2[1024], proto1[10], proto2[10];
int port1, port2;
av_url_split(proto1, sizeof(proto1), NULL, 0,
hostname1, sizeof(hostname1), &port1,
NULL, 0, s->location);
av_url_split(proto2, sizeof(proto2), NULL, 0,
hostname2, sizeof(hostname2), &port2,
NULL, 0, uri);
if (port1 != port2 || strncmp(hostname1, hostname2, sizeof(hostname2)) != 0) {
av_log(h, AV_LOG_ERROR, "Cannot reuse HTTP connection for different host: %s:%d != %s:%d\n",
hostname1, port1,
hostname2, port2
);
return AVERROR(EINVAL);
}
ret = http_shutdown(h, h->flags);
if (ret < 0)