diff mbox series

[FFmpeg-devel,1/9] lavd/jack: increase buffer size for snprintf()

Message ID 20211125150500.25040-1-anton@khirnov.net
State Accepted
Commit 007819a5bc0d3c01c0de26d9e1c6f909877e7c45
Headers show
Series [FFmpeg-devel,1/9] lavd/jack: increase buffer size for snprintf()
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Anton Khirnov Nov. 25, 2021, 3:04 p.m. UTC
Maximum output size with a 32-bit int is 17 bytes, or 26 with a 64-bit
int.

Silences the following gcc 10 warning:
src/libavdevice/jack.c: In function ‘audio_read_header’:
src/libavdevice/jack.c:171:45: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
      |                                             ^
src/libavdevice/jack.c:171:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 16
  171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 libavdevice/jack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt Nov. 26, 2021, 3:37 p.m. UTC | #1
Anton Khirnov:
> Maximum output size with a 32-bit int is 17 bytes, or 26 with a 64-bit
> int.
> 
> Silences the following gcc 10 warning:
> src/libavdevice/jack.c: In function ‘audio_read_header’:
> src/libavdevice/jack.c:171:45: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
>   171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
>       |                                             ^
> src/libavdevice/jack.c:171:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 16
>   171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ---
>  libavdevice/jack.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavdevice/jack.c b/libavdevice/jack.c
> index 31534134f3..0d5465e407 100644
> --- a/libavdevice/jack.c
> +++ b/libavdevice/jack.c
> @@ -167,7 +167,7 @@ static int start_jack(AVFormatContext *context)
>  
>      /* Register JACK ports */
>      for (i = 0; i < self->nports; i++) {
> -        char str[16];
> +        char str[32];
>          snprintf(str, sizeof(str), "input_%d", i + 1);
>          self->ports[i] = jack_port_register(self->client, str,
>                                              JACK_DEFAULT_AUDIO_TYPE,
> 

LGTM.

- Andreas
diff mbox series

Patch

diff --git a/libavdevice/jack.c b/libavdevice/jack.c
index 31534134f3..0d5465e407 100644
--- a/libavdevice/jack.c
+++ b/libavdevice/jack.c
@@ -167,7 +167,7 @@  static int start_jack(AVFormatContext *context)
 
     /* Register JACK ports */
     for (i = 0; i < self->nports; i++) {
-        char str[16];
+        char str[32];
         snprintf(str, sizeof(str), "input_%d", i + 1);
         self->ports[i] = jack_port_register(self->client, str,
                                             JACK_DEFAULT_AUDIO_TYPE,