[FFmpeg-devel] [PATCH V2 4/7] libavformat/dashenc.c: fix build warning for [-Wformat-truncation=]

Guo, Yejun yejun.guo at intel.com
Thu Feb 25 08:38:13 EET 2021


Part of warning message:
src/libavformat/dashenc.c: In function ‘flush_init_segment’:
src/libavformat/dashenc.c:608:49: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
         snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
                                                 ^~
src/libavformat/dashenc.c:608:9: note: ‘snprintf’ output between 1 and 2047 bytes into a destination of size 1024
         snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
---
 libavformat/dashenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 2d757b3a87..b11f79c966 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -126,7 +126,7 @@ typedef struct OutputStream {
     char codec_str[100];
     int written_len;
     char filename[1024];
-    char full_path[1024];
+    char full_path[2048];
     char temp_path[1024];
     double availability_time_offset;
     AVProducerReferenceTime producer_reference_time;
@@ -604,7 +604,7 @@ static int flush_init_segment(AVFormatContext *s, OutputStream *os)
 
     os->pos = os->init_range_length = range_length;
     if (!c->single_file) {
-        char filename[1024];
+        char filename[2048];
         snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
         dashenc_io_close(s, &os->out, filename);
     }
@@ -1480,7 +1480,7 @@ static int dash_init(AVFormatContext *s)
         AVFormatContext *ctx;
         AVStream *st;
         AVDictionary *opts = NULL;
-        char filename[1024];
+        char filename[2048];
 
         os->bit_rate = s->streams[i]->codecpar->bit_rate;
         if (!os->bit_rate) {
-- 
2.17.1



More information about the ffmpeg-devel mailing list