Skip to content

access: http: fix status string size warning

The asserts checks that the status is below 1000 but if it's bigger in a release build we should not limit the buffer size.

Fixes this warning/error in gcc:

access/http/message.c: In function 'vlc_http_msg_h2_frame':
access/http/message.c:412:47: error: '%hd' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Werror=format-truncation=]
  412 |         snprintf(status, ARRAY_SIZE(status), "%hd", m->status);
      |                                               ^~~
access/http/message.c:412:46: note: directive argument in the range [0, 32767]
  412 |         snprintf(status, ARRAY_SIZE(status), "%hd", m->status);
      |                                              ^~~~~
In file included from /usr/include/stdio.h:970,
                 from access/http/message.c:29:
In function 'snprintf',
    inlined from 'vlc_http_msg_h2_frame' at access/http/message.c:412:9:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:68:10: note: '__builtin___snprintf_chk' output between 2 and 6 bytes into a destination of size 4
   68 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   70 |                                    __va_arg_pack ());
      |       
                         ~~~~~~~~~~~~~~~~~
Edited by Steve Lhomme

Merge request reports

Loading