PR #23614 opened by Jun Zhao (mypopydev)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23614
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23614.patch

Four fixes in libavformat: a typo in internal.h, a swallowed error in 
ff_mkdir_p(), orphan OpenSSL declarations in
  tls.h, and a broken error check in avformat_network_init().


>From 9039f07614eb1396ad5d37afdfaabfabfea353f7 Mon Sep 17 00:00:00 2001
From: Jun Zhao <[email protected]>
Date: Sat, 27 Jun 2026 14:06:24 +0800
Subject: [PATCH 1/4] avformat/internal: fix typo allow_unkown -> allow_unknown

The declaration of ff_parse_opts_from_query_string() misspelled
"unknown" as "unkown". The implementation in utils.c already uses
the correct spelling.

Signed-off-by: Jun Zhao <[email protected]>
---
 libavformat/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index a04343989b..cf42389062 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -680,7 +680,7 @@ int ff_dict_set_timestamp(AVDictionary **dict, const char 
*key, int64_t timestam
  *                      nested protocols are used.
  * @return <0 on error
  */
-int ff_parse_opts_from_query_string(void *obj, const char *str, int 
allow_unkown);
+int ff_parse_opts_from_query_string(void *obj, const char *str, int 
allow_unknown);
 
 /**
  * Make a RFC 4281/6381 like string describing a codec.
-- 
2.52.0


>From 386845a681f245c5ecef9e361d2150588d50f714 Mon Sep 17 00:00:00 2001
From: Jun Zhao <[email protected]>
Date: Sat, 27 Jun 2026 14:06:48 +0800
Subject: [PATCH 2/4] avformat/utils: fix ff_mkdir_p() swallowing intermediate
 mkdir errors

When creating nested directories (e.g. /a/b/c), if mkdir() fails
for an intermediate component, the function continued creating
deeper directories instead of stopping. This caused the original
error code to be overwritten by subsequent failures, making
debugging harder.

Return immediately when an intermediate mkdir() fails, preserving
the errno for the caller.

Signed-off-by: Jun Zhao <[email protected]>
---
 libavformat/utils.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index c64ff27418..5ee41bfdbe 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -443,6 +443,10 @@ int ff_mkdir_p(const char *path)
             tmp_ch = *pos;
             *pos = '\0';
             ret = mkdir(temp, 0755);
+            if (ret < 0) {
+                av_free(temp);
+                return ret;
+            }
             *pos = tmp_ch;
         }
     }
-- 
2.52.0


>From ed451a86004df272153d8c9d6f15b56e02911b29 Mon Sep 17 00:00:00 2001
From: Jun Zhao <[email protected]>
Date: Sat, 27 Jun 2026 15:10:37 +0800
Subject: [PATCH 3/4] avformat/tls: remove orphan
 ff_openssl_init/ff_openssl_deinit declarations

These declarations were left behind by f0913b3f16 which
removed support for OpenSSL < 1.1.0. Since OpenSSL >= 1.1.0
auto-initializes, neither function has an implementation or
caller.

Signed-off-by: Jun Zhao <[email protected]>
---
 libavformat/tls.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavformat/tls.h b/libavformat/tls.h
index f2f4f8991f..570c245ff4 100644
--- a/libavformat/tls.h
+++ b/libavformat/tls.h
@@ -125,9 +125,6 @@ int ff_ssl_gen_key_cert(char *key_buf, size_t key_sz, char 
*cert_buf, size_t cer
 void ff_gnutls_init(void);
 void ff_gnutls_deinit(void);
 
-int ff_openssl_init(void);
-void ff_openssl_deinit(void);
-
 /**
  * Whether the packet is a DTLS packet, as defined by RFC 5764 Section 5.1.2.
  */
-- 
2.52.0


>From e84b414e9b589e878adbc069a5c92178d6cd1f9f Mon Sep 17 00:00:00 2001
From: Jun Zhao <[email protected]>
Date: Sat, 27 Jun 2026 15:22:10 +0800
Subject: [PATCH 4/4] avformat/utils: fix avformat_network_init() error check
 for ff_network_init()

ff_network_init() returns 0 on failure and 1 on success, never a
negative AVERROR code. All other callers (sapdec.c, avio.c,
rtspdec.c, rtsp.c, sapenc.c) use !ff_network_init() to check
for failure, but avformat_network_init() used a < 0 comparison
which never matched.

Change the check to match the other callers and return AVERROR(EIO)
on failure.

Signed-off-by: Jun Zhao <[email protected]>
---
 libavformat/network.c | 7 +++++++
 libavformat/utils.c   | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavformat/network.c b/libavformat/network.c
index 2b7e665bc4..764b62a35b 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -55,6 +55,13 @@ void ff_tls_deinit(void)
 #endif
 }
 
+/**
+ * Initialize the network subsystem. On Windows, this calls WSAStartup().
+ *
+ * @return 1 on success, 0 on failure. Note: this does NOT follow the
+ *         AVERROR convention (negative on error); callers should use
+ *         !ff_network_init() to check for failure.
+ */
 int ff_network_init(void)
 {
 #if HAVE_WINSOCK2_H
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5ee41bfdbe..64dab53197 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -566,8 +566,8 @@ int avformat_network_init(void)
 {
 #if CONFIG_NETWORK
     int ret;
-    if ((ret = ff_network_init()) < 0)
-        return ret;
+    if (!ff_network_init())
+        return AVERROR(EIO);
     if ((ret = ff_tls_init()) < 0)
         return ret;
 #endif
-- 
2.52.0

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

Reply via email to