From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id AB46F4EB0B for ; Sun, 15 Feb 2026 17:34:16 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'+mMN8tLNJ/ogUeJGqNSPAWNne7fEnK0NWy5pC0yaKRs=', expected b'SubVbhhD3Ig4fF2s3zpabgPB5juV62oeoPNJxzx0Skg=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771176830; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=+mMN8tLNJ/ogUeJGqNSPAWNne7fEnK0NWy5pC0yaKRs=; b=yzQPnkGnwcZJE0/dNhZ3yFLcNXoXMh4V13bU+3I0D9SjCUZQxwQMq0Fb5POCiVsMjTogA VCFZfjFXwlbRqFRRuz2n9dsfkCcYm7qFF6nEXE0TfljGcyVyBOpH2OwrC+3ceDT+0oOnjcf hcYcKzgOvNvw9Y3xnSOB+qUJm1zO968LitslhylW0r8k/DQsMJrq8GPet8KRBDNyqzkuKrJ k89ti5/nPfb6mNP3z82ssp9jq0oJ7Kz4eVltVpno1jcQHpfl/6TLgTR3xULqjWhlM3ZXplH vsKUSzk5iY0gmVYopxPhkZLe29pkrdCHBcJEaIZ2x6bmcFwn4hMsGcCImjuw== Received: from [172.20.0.3] (unknown [172.20.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 3FC5A69131F; Sun, 15 Feb 2026 19:33:50 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771176820; b=IdcO8VGgUY1PEjtsQkKIpQ0Gg+KXbYkDjNEMLn/cwpfmdbbs+G8z7vuoLz+wFoTBFiWNJ pvKhZSKgmnRL5MCzgvCgdCLRUcUejw/ux73lludxWodaj5tmGvoWfTxsoPeZd+ty2RBDQ5u D4g9sw61SaOJoNJP+/TAMbWpMzyAKqQXTSSuiO4f4SCBeTA7kZVY9XvOrGZYEuz+RVm/dds qWObobtwpYvU/C/XAXhehKqSdvXteu8neTkJco0OqGEiKaGVDKST5pG3Z7rCLnFVG16fLb1 QVgsdAJCZqa04oC+GwZKAo31LqyiZM9RDwuBDspdtLNvZEHmDhRMLJK5q2vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771176820; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=1qcTZpLaOvfHyCDD/stPA5l2T0/BJDkfYG659Kyvaiw=; b=dQAQ7R4KwZ+OsyA8mplIKW0we4Cqo5sUNXG1Xc3wMwr1vBr3BEL9H4uAl7PQpCCLUhmZY rn828hJhaAI+ASxnGRcVSukVfQptAb+t/HVXwU8Oz/qLbcbVHevUG+ySuIXeFXWIFDUcL57 veJDjuOSWYNzXLKo5y7r/B4rli/mfvWVM+wZm1JBGj/IwR1QLw5yHnrFcjodzMYbBnO0M6U YovC7DrvswL9BZtekQMl7PaDa3WAB4k1fxot58QOE0zLknWsHv1wgBa9tawV9CE0vkHX5e0 PO0J7nTeYJdIZr05X9np3KYzKfT9nNGwkBHErZgz6HvScwE9AachdXaXwOmg== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771176813; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=SubVbhhD3Ig4fF2s3zpabgPB5juV62oeoPNJxzx0Skg=; b=rQweNQrDE90ZUruazM+LIHQhIRfPPwgXkiiJfzmN+qcCrp019MMZP276VqmvlnzuurgbK wgQpihCh30FeMYCU2HnAKO7l5ybSDqKX2v13KtJOCJxnRVIyWY/rCrmj5/w8p0U+3Qz4jTJ xMVjsaCB8yk6Go7+8wccZLGdiibdSrfKcpqXGOz/dspnK7tpP4t++hBzkFnDOUdI1d/oS90 ZPe389/YtVek+qBVh059hraGM5xmktcNv5CkUYoTz/NfDC1+R9b3H8DxYVZiq2JgzLnAPrn 2vuXrKiavBSRra5tT2CEPturhBAlS4yRY4nPIGukWGS9gVZMo+ogzEAv4Vdg== Received: from c8d966988b92 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 48FE56912AF for ; Sun, 15 Feb 2026 19:33:33 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Sun, 15 Feb 2026 17:33:32 -0000 Message-ID: <177117681341.25.2921584865392573526@009cbcb3d8cd> Message-ID-Hash: IHDZKZZLKGH2FJ4LB26JSYNUPR3IFWLW X-Message-ID-Hash: IHDZKZZLKGH2FJ4LB26JSYNUPR3IFWLW X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] Various minor fixes to the HTTP protocol (PR #21765) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Niklas Haas via ffmpeg-devel Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21765 opened by Niklas Haas (haasn) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21765 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21765.patch Mostly concerning errors and edge cases >>From a0f4118bc3e730c22a9e3e51f47dd922abfd471c Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 15 Feb 2026 18:03:38 +0100 Subject: [PATCH 1/7] avformat/http: avoid int overflow This was meant to accumulate int64_t timestamp values. Fixes: b8daba42cdb4b91e793b91ef3055797b0b7611bd --- libavformat/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 805e3eff9f..8835bb9743 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -154,8 +154,8 @@ typedef struct HTTPContext { int nb_retries; int nb_reconnects; int nb_redirects; - int sum_latency; /* divide by nb_requests */ - int max_latency; + int64_t sum_latency; /* divide by nb_requests */ + int64_t max_latency; } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) -- 2.52.0 >>From b0fc5f315e52eff270b8dcdc99b2094bee5b802f Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 15 Feb 2026 18:09:15 +0100 Subject: [PATCH 2/7] avformat/http: fix http_connect() offset mismatch error code This (arbitrarily) returns -1, which happens to be AVERROR(EPERM) on my machine. Return the more descriptive AVERORR(EIO) instead. Also add a log message to explain what's going on. --- libavformat/http.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 8835bb9743..a0ed3d5c30 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1679,7 +1679,15 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, if (s->new_location) s->off = off; - err = (off == s->off) ? 0 : -1; + if (off != s->off) { + av_log(h, AV_LOG_ERROR, + "Unexpected offset: expected %"PRIu64", got %"PRIu64"\n", + off, s->off); + err = AVERROR(EIO); + goto done; + } + + err = 0; done: av_freep(&authstr); av_freep(&proxyauthstr); -- 2.52.0 >>From 1e776cb914d760a161524cc6bf077887944952b5 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 15 Feb 2026 18:12:18 +0100 Subject: [PATCH 3/7] avformat/http: avoid circular redirect infinite loop If there is a circular redirect, both redirects will get cached, at which point the next loop iteration will be stuck infinitely redirecting internally in the cycle. Avoid this by treating cached redirects as identical to uncached redirects for the purposes of incrementing the redirect loop counter. --- libavformat/http.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index a0ed3d5c30..12d7ee7229 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -416,6 +416,8 @@ redo: ret = AVERROR(ENOMEM); goto fail; } + if (redirects++ >= MAX_REDIRECTS) + return AVERROR(EIO); goto redo; } -- 2.52.0 >>From 47d47c38fe25795e8a9f31892be8d64d89244eff Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 15 Feb 2026 18:17:46 +0100 Subject: [PATCH 4/7] avformat/http: restore offset on http_open_cnx() failure The retry path restores this offset, but the failure path does not. This is especially important for the case of the continuation handler in http_read_stream(), which may result in subsequent loop iterations (after repeated failures to read additional data) seeking to the wrong offset. --- libavformat/http.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/http.c b/libavformat/http.c index 12d7ee7229..29cf82d229 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -507,6 +507,7 @@ redo: return 0; fail: + s->off = off; if (s->hd) ffurl_closep(&s->hd); if (ret < 0) -- 2.52.0 >>From de5fb6f065782e5686e81757c7bd9db6887c69cf Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 15 Feb 2026 18:28:29 +0100 Subject: [PATCH 5/7] avformat/http: move retry label (cosmetic) Move this closer to the corresponding `goto`. From the PoV of the control flow, these placements are completely identical. --- libavformat/http.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 29cf82d229..7465798c22 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1834,6 +1834,8 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) if (s->compressed) return http_buf_read_compressed(h, buf, size); #endif /* CONFIG_ZLIB */ + +retry: read_ret = http_buf_read(h, buf, size); while (read_ret < 0) { uint64_t target = h->is_streamed ? 0 : s->off; @@ -1881,7 +1883,6 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) return read_ret; } -retry: read_ret = http_buf_read(h, buf, size); } -- 2.52.0 >>From bd68207653d5468748ab953a87211fa1e1fc0e64 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 15 Feb 2026 18:29:07 +0100 Subject: [PATCH 6/7] avformat/http: close stale connection on wrong seek If http_seek_internal() gives us an unexpected position, we should close the connection to avoid leaking reading incorrect bytes on subsequent reads. --- libavformat/http.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/http.c b/libavformat/http.c index 7465798c22..1fb563a010 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1879,6 +1879,7 @@ retry: conn_attempts++; seek_ret = http_seek_internal(h, target, SEEK_SET, 1); if (seek_ret >= 0 && seek_ret != target) { + ffurl_close(&s->hd); av_log(h, AV_LOG_ERROR, "Failed to reconnect at %"PRIu64".\n", target); return read_ret; } -- 2.52.0 >>From c8867f522d301db77d9d54405701c4c8012a0641 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 15 Feb 2026 18:31:01 +0100 Subject: [PATCH 7/7] avformat/http: fix Cache-Control header parsing This was calling atoi() on `p + offset`, which is nonsense (p may point to the start of the cache-control string, which does not necessarilly coincide with the location of the max-age value). Based on the code, the intent was clearly to parse the value *after* the matched substring. --- libavformat/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 1fb563a010..e5124a5fe0 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1160,7 +1160,7 @@ static void parse_cache_control(HTTPContext *s, const char *p) } if (age) { - s->expires = time(NULL) + atoi(p + offset); + s->expires = time(NULL) + atoi(age + offset); } } -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org