From: michaelni via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: michaelni <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avformat/http: allow adjusting the redirect limit (PR #21458)
Date: Wed, 14 Jan 2026 02:28:39 -0000
Message-ID: <176835772011.25.14296558730391462393@4457048688e7> (raw)
PR #21458 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21458
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21458.patch
Idea from: BapToutatis and also curl and wget have equivalent options
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>From 9dff008ed8c2a3ba73d9d1a23f1660501e20ed8e Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael@niedermayer.cc>
Date: Wed, 14 Jan 2026 03:21:46 +0100
Subject: [PATCH] avformat/http: allow adjusting the redirect limit
Idea from: BapToutatis and also curl and wget have equivalent options
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/http.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavformat/http.c b/libavformat/http.c
index bd25a45636..cb1bd6bc20 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -146,6 +146,7 @@ typedef struct HTTPContext {
unsigned int retry_after;
int reconnect_max_retries;
int reconnect_delay_total_max;
+ int max_redirects;
} HTTPContext;
#define OFFSET(x) offsetof(HTTPContext, x)
@@ -191,6 +192,7 @@ static const AVOption options[] = {
{ "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
{ "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E},
{ "short_seek_size", "Threshold to favor readahead over seek.", OFFSET(short_seek_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
+ { "max_redirects", "Maximum number of redirects", OFFSET(max_redirects), AV_OPT_TYPE_INT, { .i64 = MAX_REDIRECTS }, 0, INT_MAX, D },
{ NULL }
};
@@ -384,6 +386,9 @@ redo:
cached = redirect_cache_get(s);
if (cached) {
+ if (redirects++ >= s->max_redirects)
+ return AVERROR(EIO);
+
av_free(s->location);
s->location = av_strdup(cached);
if (!s->location) {
@@ -452,7 +457,7 @@ redo:
s->new_location) {
/* url moved, get next */
ffurl_closep(&s->hd);
- if (redirects++ >= MAX_REDIRECTS)
+ if (redirects++ >= s->max_redirects)
return AVERROR(EIO);
if (!s->expires) {
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2026-01-14 2:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176835772011.25.14296558730391462393@4457048688e7 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git