This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/8.1
in repository ffmpeg.

The following commit(s) were added to refs/heads/release/8.1 by this push:
     new 4d786a8648 avformat/tls_gnutls:fix crash when connecting to peer
4d786a8648 is described below

commit 4d786a86486434b96263938b4ffbb4c97028402b
Author:     Aditya Banavi <[email protected]>
AuthorDate: Tue Jun 16 06:33:07 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Tue Jun 16 17:52:37 2026 +0000

    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.
    The gnutls api - gnutls_server_name_set() crashes if the hostname is NULL.
    
    This commit assigns valid value to s->host in such scenarios.
    
    Signed-off-by: Aditya Banavi <[email protected]>
    (cherry picked from commit 28b92b9b2e7abeb70b0aa050138e6e4b7cc26aed)
    
    The upstream fix calls ff_tls_parse_host(), which was introduced after this
    branch point by commit df3511db5bdf; its host-parsing is inlined here rather
    than backporting that refactor.
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavformat/tls_gnutls.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index 778ca9cf40..9bb272a308 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,21 @@ 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) {
+        /* With an external socket ff_tls_open_underlying() is skipped, so the
+         * host (used for SNI below) is never parsed. Parse it here to avoid
+         * passing a NULL s->host to gnutls_server_name_set(), which crashes. 
*/
+        struct addrinfo hints = { .ai_flags = AI_NUMERICHOST }, *ai = NULL;
+        av_url_split(NULL, 0, NULL, 0, s->underlying_host, 
sizeof(s->underlying_host),
+                     NULL, NULL, 0, uri);
+        if (!getaddrinfo(s->underlying_host, NULL, &hints, &ai)) {
+            s->numerichost = 1;
+            freeaddrinfo(ai);
+        }
+        if (!(s->host = av_strdup(s->underlying_host))) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
     }
 
     if (s->is_dtls)

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

Reply via email to