[FFmpeg-devel] [PATCH 3/4] avformat/concat: Add concat_enable option that is disable by default

Michael Niedermayer michaelni at gmx.at
Wed Jan 20 11:10:29 CET 2016


From: Michael Niedermayer <michael at niedermayer.cc>

This should prevent the unintended use of concat

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/concat.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/libavformat/concat.c b/libavformat/concat.c
index 7bcc279..a91bfb8 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -23,6 +23,7 @@
 
 #include "libavutil/avstring.h"
 #include "libavutil/mem.h"
+#include "libavutil/opt.h"
 
 #include "avformat.h"
 #include "url.h"
@@ -35,11 +36,32 @@ struct concat_nodes {
 };
 
 struct concat_data {
+    AVClass *class;
+    int concat_enable;
     struct concat_nodes *nodes;    ///< list of nodes to concat
     size_t               length;   ///< number of cat'ed nodes
     size_t               current;  ///< index of currently read node
 };
 
+#define OFFSET(field) offsetof(struct concat_data, field)
+#define D AV_OPT_FLAG_DECODING_PARAM
+
+static const AVOption concat_options[] = {
+    { "concat_enable", "Enable concat", OFFSET(concat_enable), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D },
+    { NULL }
+};
+
+#undef OFFSET
+#undef D
+
+static const AVClass concat_class = {
+    .class_name = "concat",
+    .item_name  = av_default_item_name,
+    .option     = concat_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+
 static av_cold int concat_close(URLContext *h)
 {
     int err = 0;
@@ -70,6 +92,11 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
         return AVERROR(EINVAL);
     }
 
+    if (!data->concat_enable) {
+        av_log(h, AV_LOG_ERROR, "Concat is not enabled see the concat_enable option\n");
+        return AVERROR(EPERM);
+    }
+
     for (i = 0, len = 1; uri[i]; i++) {
         if (uri[i] == *AV_CAT_SEPARATOR) {
             /* integer overflow */
@@ -192,4 +219,5 @@ URLProtocol ff_concat_protocol = {
     .url_seek       = concat_seek,
     .url_close      = concat_close,
     .priv_data_size = sizeof(struct concat_data),
+    .priv_data_class= &concat_class,
 };
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list