PR #22567 opened by qwerzoid
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22567
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22567.patch

When ffmpeg whip client takes up dtls_active role when using gnutls,
it tries to connect to the server over udp and intermittently crashes.
This is because s->host is NULL, and ffmpeg is in ice controlling mode.

This commit assigns valid value to s->host in such scenarios.

Signed-off-by: Aditya Banavi <[email protected]>


>From 41fef1cb8c48015f14acccd93ad2613f7d3bf4ef Mon Sep 17 00:00:00 2001
From: Aditya Banavi <[email protected]>
Date: Fri, 20 Mar 2026 16:08:22 +0000
Subject: [PATCH] avformat/tls_gnutls:fix crash when connecting to peer

When ffmpeg whip client takes up dtls_active role when using gnutls,
it tries to connect to the server over udp and intermittently crashes.
This is because s->host is NULL, and ffmpeg is in ice controlling mode.

This commit assigns valid value to s->host in such scenarios.

Signed-off-by: Aditya Banavi <[email protected]>
---
 libavformat/tls_gnutls.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index e294aef0c0..a38f7eaa19 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -31,6 +31,7 @@
 #include "url.h"
 #include "tls.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "libavutil/random_seed.h"
@@ -538,6 +539,17 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
     if (!s->external_sock) {
         if ((ret = ff_tls_open_underlying(s, h, uri, options)) < 0)
             goto fail;
+    } else if (!s->host) {
+        char hostname[256];
+        struct addrinfo hints = { .ai_flags = AI_NUMERICHOST }, *ai;
+        av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), NULL, NULL, 
0, uri);
+        if (hostname[0]) {
+            s->host = av_strdup(hostname);
+            if (!getaddrinfo(hostname, NULL, &hints, &ai)) {
+                s->numerichost = 1;
+                freeaddrinfo(ai);
+            }
+        }
     }
 
     if (s->is_dtls)
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to