* [FFmpeg-devel] [PATCH] libavformat/vorbiscomment.c:fix warning:‘%03d’directive output may be truncated (PR #20433)
@ 2025-09-04 12:28 caifan via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: caifan via ffmpeg-devel @ 2025-09-04 12:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: caifan
PR #20433 opened by caifan
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20433
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20433.patch
libavformat/vorbiscomment.c:103:63: warning: ‘%03d’ directive output may be truncated writing between 3 and 10 bytes into a region of size 4 [-Wformat-truncation=]
snprintf(chapter_number, sizeof(chapter_number), "%03d", i);
| ^~~~
warning:‘%02d’ directive output may be truncated writing between 2 and 3 bytes into a region of size between 1 and 7 [-Wformat-truncation=]snprintf(chapter_time, sizeof(chapter_time), "%02d:%02d:%02d.%03d", h, m, s, ms);
| ^~~~
libavformat/vorbiscomment.c:104:58: note: directive argument in the range [-59, 59]
104 | snprintf(chapter_time, sizeof(chapter_time), "%02d:%02d:%02d.%03d", h, m, s, ms);
| ^~~~~~~~~~~~~~~~~~~~~
libavformat/vorbiscomment.c:104:58: note: directive argument in the range [-999, 999]
In function ‘snprintf’,
inlined from ‘ff_vorbiscomment_write’ at libavformat/vorbiscomment.c:104:13:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 13 and 21 bytes into a destination of size 13
71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
Signed-off-by: caifan3 <caifan3@xiaomi.com>
From df9bf99804e9954879c8ea55bbcc0d5e17761268 Mon Sep 17 00:00:00 2001
From: caifan3 <caifan3@xiaomi.com>
Date: Thu, 4 Sep 2025 20:14:02 +0800
Subject: [PATCH] =?UTF-8?q?libavformat/vorbiscomment.c:fix=20warning:?=
=?UTF-8?q?=E2=80=98%03d=E2=80=99directive=20output=20may=20be=20truncated?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
libavformat/vorbiscomment.c:103:63: warning: ‘%03d’ directive output may be truncated writing between 3 and 10 bytes into a region of size 4 [-Wformat-truncation=]
snprintf(chapter_number, sizeof(chapter_number), "%03d", i);
| ^~~~
warning:‘%02d’ directive output may be truncated writing between 2 and 3 bytes into a region of size between 1 and 7 [-Wformat-truncation=]snprintf(chapter_time, sizeof(chapter_time), "%02d:%02d:%02d.%03d", h, m, s, ms);
| ^~~~
libavformat/vorbiscomment.c:104:58: note: directive argument in the range [-59, 59]
104 | snprintf(chapter_time, sizeof(chapter_time), "%02d:%02d:%02d.%03d", h, m, s, ms);
| ^~~~~~~~~~~~~~~~~~~~~
libavformat/vorbiscomment.c:104:58: note: directive argument in the range [-999, 999]
In function ‘snprintf’,
inlined from ‘ff_vorbiscomment_write’ at libavformat/vorbiscomment.c:104:13:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 13 and 21 bytes into a destination of size 13
71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
Signed-off-by: caifan3 <caifan3@xiaomi.com>
---
| 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--git a/libavformat/vorbiscomment.c b/libavformat/vorbiscomment.c
index abe12fd586..fb2ea7eba1 100644
--- a/libavformat/vorbiscomment.c
+++ b/libavformat/vorbiscomment.c
@@ -91,8 +91,8 @@ int ff_vorbiscomment_write(AVIOContext *pb, const AVDictionary *m,
}
for (int i = 0; i < nb_chapters; i++) {
AVChapter *chp = chapters[i];
- char chapter_time[13];
- char chapter_number[4];
+ char chapter_time[22];
+ char chapter_number[11];
int h, m, s, ms;
s = av_rescale(chp->start, chp->time_base.num, chp->time_base.den);
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-04 12:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 12:28 [FFmpeg-devel] [PATCH] libavformat/vorbiscomment.c:fix warning:‘%03d’directive output may be truncated (PR #20433) caifan via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git