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 <[email protected]> >From 9dff008ed8c2a3ba73d9d1a23f1660501e20ed8e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> 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 <[email protected]> --- 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 -- [email protected] To unsubscribe send an email to [email protected]
