[FFmpeg-devel] [PATCH 1/1] libavformat/img2enc.c: rm warning ‘.tmp’ directive output may be truncated
Cai Fan
caifan0425 at 163.com
Wed Jul 30 06:43:24 EEST 2025
Signed-off-by: Cai Fan <caifan0425 at 163.com>
---
libavformat/img2enc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 41638d92b8..f7d983ec54 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -180,6 +180,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
}
for (i = 0; i < 4; i++) {
av_dict_copy(&options, img->protocol_opts, 0);
+ if (strlen(filename) + 5 >= sizeof(img->tmp[i])) {
+ av_log(s, AV_LOG_ERROR, "Filename too long: %s\n", filename);
+ ret = AVERROR(EINVAL);
+ goto fail;
+ }
snprintf(img->tmp[i], sizeof(img->tmp[i]), "%s.tmp", filename);
av_strlcpy(img->target[i], filename, sizeof(img->target[i]));
if (s->io_open(s, &pb[i], img->use_rename ? img->tmp[i] : filename, AVIO_FLAG_WRITE, &options) < 0) {
--
2.34.1
More information about the ffmpeg-devel
mailing list