Skip to content

Question about bugs in gcc in (v)(s)(n)printf() functions #27025

@Jamaika1

Description

@Jamaika1

Were the bugs fixed in gcc 15.x.x (v)(s)(n)printf()?

matroskaenc.c:3349:79: warning: '%012.9f' directive output may be truncated writing between 12 and 320 bytes into a region of size between 8 and 14 [-Wformat-truncation=]
 3349 |                 snprintf(duration_string, sizeof(duration_string), "%02d:%02d:%012.9f",
      |                                                                               ^~~~~~~
matroskaenc.c:3349:17: note: 'snprintf' output between 19 and 333 bytes into a destination of size 20
 3349 |                 snprintf(duration_string, sizeof(duration_string), "%02d:%02d:%012.9f",
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3350 |                          (int) duration_sec / 3600, ((int) duration_sec / 60) % 60,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3351 |                          fmod(duration_sec, 60));
      |                          ~~~~~~~~~~~~~~~~~~~~~~~

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113752
Which form is correct?

#ifdef __MINGW32__
char duration_string[333] = "";
#else
char duration_string[DURATION_STRING_LENGTH + 1] = "";
#endif

or

#ifdef __MINGW32__
__mingw_snprintf(duration_string, sizeof(duration_string), "%02d:%02d:%012.9f",
#else
snprintf(duration_string, sizeof(duration_string), "%02d:%02d:%012.9f",
#endif

Edit:
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21291

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions