PR #20541 opened by Marvin Scholz (ePirat)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20541
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20541.patch

- Fix leading space in the RTSP reason string
- Avoid logging invalid values and instead properly log warnings on failure 
reading RTSP data


>From f6d11e63faaa7aaadd1e27a18a96a65581f50a34 Mon Sep 17 00:00:00 2001
From: Marvin Scholz <[email protected]>
Date: Fri, 22 Aug 2025 16:50:34 +0200
Subject: [PATCH 1/2] 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.
---
 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 614a5682ec349a1ca3daba19613ae93343932e08 Mon Sep 17 00:00:00 2001
From: Marvin Scholz <[email protected]>
Date: Fri, 22 Aug 2025 21:41:26 +0200
Subject: [PATCH 2/2] 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.
---
 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 -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to