[asterisk-bugs] [JIRA] (ASTERISK-29145) GCC Warnings with OPTIMIZE=-Os make

Alexander Traud (JIRA) noreply at issues.asterisk.org
Thu Oct 29 08:59:15 CDT 2020


Alexander Traud created ASTERISK-29145:
------------------------------------------

             Summary: GCC Warnings with OPTIMIZE=-Os make
                 Key: ASTERISK-29145
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-29145
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
          Components: Utilities/muted
    Affects Versions: 18.0.0, 16.14.0
            Reporter: Alexander Traud
            Severity: Trivial


{code}./configure
OPTIMIZE=-Og make{code}gives the following warning in Ubuntu 20.10 with GCC 10.2:{code}muted.c: In function ‘load_config’:
muted.c:171:36: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 256 [-Wformat-truncation=]
  171 |      snprintf(pass, sizeof(pass), "%s", val);
      |                                    ^~
In file included from /usr/include/stdio.h:866,
                 from muted.c:61:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:70:10: note: ‘__builtin_snprintf’ output between 1 and 1024 bytes into a destination of size 256
   70 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   71 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
muted.c:166:36: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 256 [-Wformat-truncation=]
  166 |      snprintf(user, sizeof(user), "%s", val);
      |                                    ^~
In file included from /usr/include/stdio.h:866,
                 from muted.c:61:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:70:10: note: ‘__builtin_snprintf’ output between 1 and 1024 bytes into a destination of size 256
   70 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   71 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{code}The workaround is trivial because this warning can be ignored. However, when using {{./configure --enable-developer-mode}} that warning turns into an error. Surprisingly, that warning does not happen with any other [optimization options|http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html] like ones normally used in Asterisk: {{-O0}} and {{-O3}}. Only {{-Og}}, {{-O1}}, and {{-Os}} are affected.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list