From: Marvin Scholz via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Marvin Scholz <code@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] Backport HTTP and RTSP fixes (PR #20635) Date: Wed, 01 Oct 2025 11:11:59 -0000 Message-ID: <175931712020.69.1278726322138558190@bf249f23a2c8> (raw) PR #20635 opened by Marvin Scholz (ePirat) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20635 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20635.patch Backports #20541 and #20542 to 8.0 and I would also ideally like to backport those to 7.1 if there are no objections. >From 09a6b6e981d5fea72182002ed94e93c24dee6b37 Mon Sep 17 00:00:00 2001 From: Marvin Scholz <epirat07@gmail.com> Date: Thu, 22 May 2025 20:14:49 +0200 Subject: [PATCH 1/3] avformat/http: Handle IPv6 Zone ID in hostname When using a literal IPv6 address as hostname, it can contain a Zone ID especially in the case of link-local addresses. Sending this to the server in the Host header is not useful to the server and in some cases servers refuse such requests. To prevent any such issues, strip the Zone ID from the address if it's an IPv6 address. This also removes it for the Cookies lookup. Based on a patch by: Daniel N Pettersson <danielnp@axis.com> (cherry picked from commit 5cb6d2221a6d4c07453b6c301ecfcaed48402680) Signed-off-by: Marvin Scholz <epirat07@gmail.com> --- libavformat/http.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 0d4077512b..49d750b512 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -24,6 +24,7 @@ #include "config.h" #include "config_components.h" +#include <string.h> #include <time.h> #if CONFIG_ZLIB #include <zlib.h> @@ -214,7 +215,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) const char *path, *proxy_path, *lower_proto = "tcp", *local_path; char *env_http_proxy, *env_no_proxy; char *hashmark; - char hostname[1024], hoststr[1024], proto[10]; + char hostname[1024], hoststr[1024], proto[10], tmp_host[1024]; char auth[1024], proxyauth[1024] = ""; char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE + 1]; char buf[1024], urlbuf[MAX_URL_SIZE]; @@ -224,7 +225,14 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) av_url_split(proto, sizeof(proto), auth, sizeof(auth), hostname, sizeof(hostname), &port, path1, sizeof(path1), s->location); - ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL); + + 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 + // can be used in the Zone ID itself. + if (strchr(tmp_host, ':')) + tmp_host[strcspn(tmp_host, "%")] = '\0'; + ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, tmp_host, port, NULL); env_http_proxy = getenv_utf8("http_proxy"); proxy_path = s->http_proxy ? s->http_proxy : env_http_proxy; -- 2.49.1 >From 624219121ea6cc21cfb2ca0b377b71642c14ff52 Mon Sep 17 00:00:00 2001 From: Marvin Scholz <epirat07@gmail.com> Date: Fri, 22 Aug 2025 16:50:34 +0200 Subject: [PATCH 2/3] avformat/rtsp: do not log invalid values When reading fails the first time, ch would be uninitialized and printed in the log message. Instead check for an error early and log it properly. (cherry picked from commit 2ed47ab72509bbee60288d245a0aebb7eb05e41a) Signed-off-by: Marvin Scholz <epirat07@gmail.com> --- libavformat/rtsp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 10355b89b8..13507d1858 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1239,9 +1239,12 @@ start: q = buf; for (;;) { ret = ffurl_read_complete(rt->rtsp_hd, &ch, 1); + if (ret != 1) { + ret = (ret < 0) ? ret : AVERROR(EIO); + av_log(s, AV_LOG_WARNING, "Failed reading RTSP data: %s\n", av_err2str(ret)); + return ret; + } av_log(s, AV_LOG_TRACE, "ret=%d c=%02x [%c]\n", ret, ch, ch); - if (ret != 1) - return ret < 0 ? ret : AVERROR(EIO); if (ch == '\n') break; if (ch == '$' && q == buf) { -- 2.49.1 >From aab883b4959b4ffee7a9edc7cf742863ce63f422 Mon Sep 17 00:00:00 2001 From: Marvin Scholz <epirat07@gmail.com> Date: Fri, 22 Aug 2025 21:41:26 +0200 Subject: [PATCH 3/3] avformat/rtsp: fix leading space in RTSP reason When parsing the RTSP message reason, the whole remainder after parsing the status code was used, which would lead to a leading space in the parsed reason string. (cherry picked from commit e63e040f0cef2d6af2fb57aefa6250fc450fa049) Signed-off-by: Marvin Scholz <epirat07@gmail.com> --- libavformat/rtsp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 13507d1858..d601d63a89 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1274,6 +1274,7 @@ start: if (!strncmp(buf1, "RTSP/", 5)) { get_word(buf1, sizeof(buf1), &p); reply->status_code = atoi(buf1); + p += strspn(p, SPACE_CHARS); av_strlcpy(reply->reason, p, sizeof(reply->reason)); } else { av_strlcpy(reply->reason, buf1, sizeof(reply->reason)); // method -- 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:[~2025-10-01 11:12 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=175931712020.69.1278726322138558190@bf249f23a2c8 \ --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 http://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/ http://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