[FFmpeg-cvslog] avformat/libsrt: Fix srt:// URL query string parsing

Ingo Oppermann git at videolan.org
Thu Feb 15 01:42:03 EET 2024


ffmpeg | branch: master | Ingo Oppermann <ingo at datarhei.com> | Mon Feb 12 15:53:19 2024 +0100| [86128bd07a8634fb4a19c1bab616bc16ce0567d3] | committer: Marton Balint

avformat/libsrt: Fix srt:// URL query string parsing

Add missing NULL check and use ff_urldecode for string query
parameters.

Signed-off-by: Ingo Oppermann <ingo at datarhei.com>
Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86128bd07a8634fb4a19c1bab616bc16ce0567d3
---

 libavformat/Makefile |  2 +-
 libavformat/libsrt.c | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 05b9b8a115..9e8e7c9cb8 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -714,7 +714,7 @@ OBJS-$(CONFIG_LIBRTMPS_PROTOCOL)         += librtmp.o
 OBJS-$(CONFIG_LIBRTMPT_PROTOCOL)         += librtmp.o
 OBJS-$(CONFIG_LIBRTMPTE_PROTOCOL)        += librtmp.o
 OBJS-$(CONFIG_LIBSMBCLIENT_PROTOCOL)     += libsmbclient.o
-OBJS-$(CONFIG_LIBSRT_PROTOCOL)           += libsrt.o
+OBJS-$(CONFIG_LIBSRT_PROTOCOL)           += libsrt.o urldecode.o
 OBJS-$(CONFIG_LIBSSH_PROTOCOL)           += libssh.o
 OBJS-$(CONFIG_LIBZMQ_PROTOCOL)           += libzmq.o
 
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 93e9cf0c08..56acb6e741 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -32,6 +32,7 @@
 #include "network.h"
 #include "os_support.h"
 #include "url.h"
+#include "urldecode.h"
 
 /* This is for MPEG-TS and it's a default SRTO_PAYLOADSIZE for SRTT_LIVE (8 TS packets) */
 #ifndef SRT_LIVE_DEFAULT_PAYLOAD_SIZE
@@ -547,7 +548,11 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         }
         if (av_find_info_tag(buf, sizeof(buf), "passphrase", p)) {
             av_freep(&s->passphrase);
-            s->passphrase = av_strndup(buf, strlen(buf));
+            s->passphrase = ff_urldecode(buf, 1);
+            if (!s->passphrase) {
+                ret = AVERROR(ENOMEM);
+                goto err;
+            }
         }
 #if SRT_VERSION_VALUE >= 0x010302
         if (av_find_info_tag(buf, sizeof(buf), "enforced_encryption", p)) {
@@ -632,7 +637,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         }
         if (av_find_info_tag(buf, sizeof(buf), "streamid", p)) {
             av_freep(&s->streamid);
-            s->streamid = av_strdup(buf);
+            s->streamid = ff_urldecode(buf, 1);
             if (!s->streamid) {
                 ret = AVERROR(ENOMEM);
                 goto err;
@@ -640,7 +645,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         }
         if (av_find_info_tag(buf, sizeof(buf), "smoother", p)) {
             av_freep(&s->smoother);
-            s->smoother = av_strdup(buf);
+            s->smoother = ff_urldecode(buf, 1);
             if(!s->smoother) {
                 ret = AVERROR(ENOMEM);
                 goto err;
@@ -671,6 +676,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
 err:
     av_freep(&s->smoother);
     av_freep(&s->streamid);
+    av_freep(&s->passphrase);
     srt_cleanup();
     return ret;
 }



More information about the ffmpeg-cvslog mailing list