This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 88fbd111eadae5661b535afccc82cb6770568695 Author: Michael Niedermayer <[email protected]> AuthorDate: Thu Sep 17 22:10:19 2026 +0200 Commit: michaelni <[email protected]> CommitDate: Sat Sep 19 18:53:13 2026 +0000 avformat/http: match cookies against the host name, not host:port get_cookies() was handed the "host:port" string used for the Host header and compared it with the cookie Domain attribute, so a cookie carrying a Domain never matched a URL with an explicit port. RFC 6265 section 8.5 ignores ports for cookie scoping. Found during triage/review of security report u2ys08MO8oEF --- libavformat/http.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index fff0f25e36..d0dc76a5aa 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -91,6 +91,7 @@ typedef struct HTTPContext { uint8_t *post_data; int post_datalen; char *cookies; ///< holds newline (\n) delimited Set-Cookie header field values (without the "Set-Cookie: " field name) + char *host; int icy; char *icy_metadata_headers; char *icy_metadata_packet; @@ -262,6 +263,11 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) hostname, sizeof(hostname), &port, path1, sizeof(path1), s->location); + av_freep(&s->host); + s->host = av_strdup(hostname); + if (!s->host) + return AVERROR(ENOMEM); + av_strlcpy(tmp_host, hostname, sizeof(tmp_host)); // In case of an IPv6 address, we need to strip the Zone ID, // if any. We do it at the first % sign, as percent encoding @@ -821,6 +827,7 @@ bail_out: av_dict_free(&s->redirect_cache); av_freep(&s->new_location); av_freep(&s->uri); + av_freep(&s->host); } return ret; } @@ -1393,8 +1400,7 @@ static int process_line(URLContext *h, char *line, int line_count, int *parsed_h * * @return a negative value if an error condition occurred, 0 otherwise */ -static int get_cookies(HTTPContext *s, char **cookies, const char *path, - const char *domain) +static int get_cookies(HTTPContext *s, char **cookies, const char *path) { // cookie strings will look like Set-Cookie header field values. Multiple // Set-Cookie fields will result in multiple values delimited by a newline @@ -1443,12 +1449,12 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path, // if no domain in the cookie assume it applied to this request if ((e = av_dict_get(cookie_params, "domain", NULL, 0)) && e->value) { // find the offset comparison is on the min domain (b.com, not a.b.com) - int domain_offset = strlen(domain) - strlen(e->value); + int domain_offset = strlen(s->host) - strlen(e->value); if (domain_offset < 0) goto skip_cookie; // match the cookie domain - if (av_strcasecmp(&domain[domain_offset], e->value)) + if (av_strcasecmp(&s->host[domain_offset], e->value)) goto skip_cookie; } @@ -1689,7 +1695,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, av_bprintf(&request, "Content-Type: %s\r\n", s->content_type); if (!has_header(s->headers, "\r\nCookie: ") && s->cookies) { char *cookies = NULL; - if (!get_cookies(s, &cookies, path, hoststr) && cookies) { + if (!get_cookies(s, &cookies, path) && cookies) { av_bprintf(&request, "Cookie: %s\r\n", cookies); av_free(cookies); } @@ -2141,6 +2147,7 @@ static int http_close(URLContext *h) av_dict_free(&s->redirect_cache); av_freep(&s->new_location); av_freep(&s->uri); + av_freep(&s->host); av_log(h, AV_LOG_DEBUG, "Statistics: %d connection%s, %d request%s, %d retr%s, %d reconnection%s, %d redirect%s\n", s->nb_connections, s->nb_connections == 1 ? "" : "s", -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
