From 9bc3aee6fbc16ee357eb4cd925e64446d570314d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 24 Feb 2025 03:50:20 +0100 Subject: [PATCH] stream/stream: mark mf:// and edl:// as unsafe protocols --- player/command.c | 2 +- stream/stream.c | 6 ++++-- stream/stream.h | 2 +- stream/stream_edl.c | 1 + stream/stream_mf.c | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/player/command.c b/player/command.c index b258584623..49e3456ef0 100644 --- a/player/command.c +++ b/player/command.c @@ -3557,7 +3557,7 @@ static int mp_property_protocols(void *ctx, struct m_property *prop, { switch (action) { case M_PROPERTY_GET: - *(char ***)arg = stream_get_proto_list(); + *(char ***)arg = stream_get_proto_list(false); return M_PROPERTY_OK; case M_PROPERTY_GET_TYPE: *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST}; diff --git a/stream/stream.c b/stream/stream.c index 1ab23630aa..f0cd52d8b0 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -882,12 +882,14 @@ struct bstr stream_read_file2(const char *filename, void *talloc_ctx, return res; } -char **stream_get_proto_list(void) +char **stream_get_proto_list(bool safe_only) { char **list = NULL; int num = 0; for (int i = 0; i < MP_ARRAY_SIZE(stream_list); i++) { const stream_info_t *stream_info = stream_list[i]; + if (safe_only && (stream_info->stream_origin & STREAM_ORIGIN_UNSAFE)) + continue; char **get_protocols = stream_info->get_protocols ? stream_info->get_protocols() : NULL; char **protocols = get_protocols ? get_protocols : (char **)stream_info->protocols; @@ -910,7 +912,7 @@ void stream_print_proto_list(struct mp_log *log) int count = 0; mp_info(log, "Protocols:\n\n"); - char **list = stream_get_proto_list(); + char **list = stream_get_proto_list(false); for (int i = 0; list[i]; i++) { mp_info(log, " %s://\n", list[i]); count++; diff --git a/stream/stream.h b/stream/stream.h index 10d4113d21..fb62fdd1e4 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -282,7 +282,7 @@ void mp_setup_av_network_options(struct AVDictionary **dict, struct mp_log *log); void stream_print_proto_list(struct mp_log *log); -char **stream_get_proto_list(void); +char **stream_get_proto_list(bool safe_only); bool stream_has_proto(const char *proto); #endif /* MPLAYER_STREAM_H */ diff --git a/stream/stream_edl.c b/stream/stream_edl.c index 94bbe58c88..e5cba4c38f 100644 --- a/stream/stream_edl.c +++ b/stream/stream_edl.c @@ -14,4 +14,5 @@ const stream_info_t stream_info_edl = { .name = "edl", .open = s_open, .protocols = (const char*const[]){"edl", NULL}, + .stream_origin = STREAM_ORIGIN_UNSAFE, }; diff --git a/stream/stream_mf.c b/stream/stream_mf.c index 0562d86b86..e28e375c1f 100644 --- a/stream/stream_mf.c +++ b/stream/stream_mf.c @@ -37,5 +37,5 @@ const stream_info_t stream_info_mf = { .name = "mf", .open = mf_stream_open, .protocols = (const char*const[]){ "mf", NULL }, - .stream_origin = STREAM_ORIGIN_FS, + .stream_origin = STREAM_ORIGIN_FS | STREAM_ORIGIN_UNSAFE, };