[FFmpeg-devel] [PATCH 1/1] libavformat/img2enc.c: rm warning ‘.tmp’ directive output may be truncated

Steven Liu lingjiujianke at gmail.com
Mon Jul 28 12:51:31 EEST 2025


Cai Fan <caifan0425 at 163.com> 于2025年7月28日周一 11:45写道:
>
> Signed-off-by: Cai Fan <caifan0425 at 163.com>
> ---
>  libavformat/img2enc.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
> index 41638d92b8..672cfe18fd 100644
> --- a/libavformat/img2enc.c
> +++ b/libavformat/img2enc.c
> @@ -180,6 +180,10 @@ 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);
> +            return AVERROR(EINVAL);

need free options.

should ret = AVERROR(EINVAL);
and 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
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list