[FFmpeg-devel] [PATCH 4/4] avformat/subfile: Add subfile_enable option that is disable by default

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


From: Michael Niedermayer <michael at niedermayer.cc>

This should prevent the unintended use of subfile

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

diff --git a/libavformat/subfile.c b/libavformat/subfile.c
index 0e84384..3fbbb16 100644
--- a/libavformat/subfile.c
+++ b/libavformat/subfile.c
@@ -30,6 +30,7 @@ typedef struct SubfileContext {
     int64_t start;
     int64_t end;
     int64_t pos;
+    int subfile_enable;
 } SubfileContext;
 
 #define OFFSET(field) offsetof(SubfileContext, field)
@@ -38,6 +39,7 @@ typedef struct SubfileContext {
 static const AVOption subfile_options[] = {
     { "start", "start offset", OFFSET(start), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
     { "end",   "end offset",   OFFSET(end),   AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
+    { "subfile_enable", "Enable subfile", OFFSET(subfile_enable), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D },
     { NULL }
 };
 
@@ -72,6 +74,11 @@ static int subfile_open(URLContext *h, const char *filename, int flags,
     SubfileContext *c = h->priv_data;
     int ret;
 
+    if (!c->subfile_enable) {
+        av_log(h, AV_LOG_ERROR, "Subfile is not enabled see the subfile_enable option\n");
+        return AVERROR(EPERM);
+    }
+
     if (c->end <= c->start) {
         av_log(h, AV_LOG_ERROR, "end before start\n");
         return AVERROR(EINVAL);
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list