[FFmpeg-devel] [PATCH 1/5] libavformat/concatdec: remove support for unsafe=-1.

Nicolas George george at nsup.org
Wed Jul 28 15:15:12 EEST 2021


It only makes sense as the default value,
but it is not the default since 689211d5727231c3fe92762d224dbadebdbf4e30.

Signed-off-by: Nicolas George <george at nsup.org>
---
 doc/demuxers.texi       | 9 +++------
 libavformat/concatdec.c | 6 ++----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 5b8cf1bfea..5f18e4551b 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -96,8 +96,7 @@ backslash or single quotes.
 All subsequent file-related directives apply to that file.
 
 @item @code{ffconcat version 1.0}
-Identify the script type and version. It also sets the @option{safe} option
-to 1 if it was -1.
+Identify the script type and version.
 
 To make FFmpeg recognize the format automatically, this directive must
 appear exactly as is (no extra space or byte-order-mark) on the very first
@@ -177,7 +176,8 @@ This demuxer accepts the following option:
 @table @option
 
 @item safe
-If set to 1, reject unsafe file paths. A file path is considered safe if it
+If set to 1, reject unsafe file paths and directives.
+A file path is considered safe if it
 does not contain a protocol specification and is relative and all components
 only contain characters from the portable character set (letters, digits,
 period, underscore and hyphen) and have no period at the beginning of a
@@ -187,9 +187,6 @@ If set to 0, any file name is accepted.
 
 The default is 1.
 
--1 is equivalent to 1 if the format was automatically
-probed and 0 otherwise.
-
 @item auto_convert
 If set to 1, try to perform automatic conversions on packet data to make the
 streams concatenable.
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 74354fce25..3db1693725 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -117,7 +117,7 @@ static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,
     size_t url_len;
     int ret;
 
-    if (cat->safe > 0 && !safe_filename(filename)) {
+    if (cat->safe && !safe_filename(filename)) {
         av_log(avf, AV_LOG_ERROR, "Unsafe file name '%s'\n", filename);
         FAIL(AVERROR(EPERM));
     }
@@ -475,8 +475,6 @@ static int concat_read_header(AVFormatContext *avf)
                 av_log(avf, AV_LOG_ERROR, "Line %d: invalid version\n", line);
                 FAIL(AVERROR_INVALIDDATA);
             }
-            if (cat->safe < 0)
-                cat->safe = 1;
         } else {
             av_log(avf, AV_LOG_ERROR, "Line %d: unknown keyword '%s'\n",
                    line, keyword);
@@ -756,7 +754,7 @@ static int concat_seek(AVFormatContext *avf, int stream,
 
 static const AVOption options[] = {
     { "safe", "enable safe mode",
-      OFFSET(safe), AV_OPT_TYPE_BOOL, {.i64 = 1}, -1, 1, DEC },
+      OFFSET(safe), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC },
     { "auto_convert", "automatically convert bitstream format",
       OFFSET(auto_convert), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC },
     { "segment_time_metadata", "output file segment start time and duration as packet metadata",
-- 
2.30.2



More information about the ffmpeg-devel mailing list