Commit a7c5ac8727 for ffmpeg
commit a7c5ac872723dc5725fc3e8b4f3c9596238ecb5a
Author: Felipe Araújo <felipdsa21@outlook.com>
Date: Sat Oct 10 03:16:03 2026 -0300
avformat/file: replace misleading url_check on pipe and fd protocols
file_check treats the URL as a file path, so for the pipe and fd protocols its
result depends on whether a file with that name happens to exist.
A real check is not possible, since the descriptor comes from an option and
avio_check does not pass options. Fully removing the check would make
avio_check open the descriptor instead, which for seekable output rewinds it.
So report the check as explicitly unsupported.
Signed-off-by: Felipe Araújo <felipdsa21@outlook.com>
diff --git a/libavformat/file.c b/libavformat/file.c
index 71d30a25c4..fb344aef93 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -223,6 +223,15 @@ static int fd_dup(URLContext *h, int oldfd)
}
#endif
+#if CONFIG_FD_PROTOCOL || CONFIG_PIPE_PROTOCOL
+/* Without a check, avio_check() would open the descriptor, rewinding seekable
+ * output. It cannot pass the option selecting the descriptor, so just fail. */
+static int fd_check(URLContext *h, int mask)
+{
+ return AVERROR(ENOSYS);
+}
+#endif
+
static int file_close(URLContext *h)
{
FileContext *c = h->priv_data;
@@ -481,7 +490,7 @@ const URLProtocol ff_pipe_protocol = {
.url_write = file_write,
.url_close = file_close,
.url_get_file_handle = file_get_handle,
- .url_check = file_check,
+ .url_check = fd_check,
.priv_data_size = sizeof(FileContext),
.priv_data_class = &pipe_class,
.default_whitelist = "crypto,data"
@@ -527,7 +536,7 @@ const URLProtocol ff_fd_protocol = {
.url_seek = file_seek,
.url_close = file_close,
.url_get_file_handle = file_get_handle,
- .url_check = file_check,
+ .url_check = fd_check,
.priv_data_size = sizeof(FileContext),
.priv_data_class = &fd_class,
.default_whitelist = "crypto,data"
@@ -687,7 +696,6 @@ const URLProtocol ff_android_content_protocol = {
.url_seek = file_seek,
.url_close = file_close,
.url_get_file_handle = file_get_handle,
- .url_check = NULL,
.priv_data_size = sizeof(FileContext),
.priv_data_class = &android_content_class,
};