[asterisk-bugs] [JIRA] (ASTERISK-29146) GCC Warnings: ‘%s’ directive argument is null.

Friendly Automation (JIRA) noreply at issues.asterisk.org
Tue Nov 3 15:36:15 CST 2020


    [ https://issues.asterisk.org/jira/browse/ASTERISK-29146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=252630#comment-252630 ] 

Friendly Automation commented on ASTERISK-29146:
------------------------------------------------

Change 15110 merged by Friendly Automation:
Compiler fixes for GCC when printf %s is NULL

[https://gerrit.asterisk.org/c/asterisk/+/15110|https://gerrit.asterisk.org/c/asterisk/+/15110]

> GCC Warnings: ‘%s’ directive argument is null.
> ----------------------------------------------
>
>                 Key: ASTERISK-29146
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-29146
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: . I did not set the category correctly.
>    Affects Versions: 16.14.0, 18.0.0
>            Reporter: Alexander Traud
>            Assignee: Alexander Traud
>            Severity: Trivial
>
> In Ubuntu 20.10 with GCC 10.2, a simple
> {code}./configure
> make{code}gives{code}In function ‘handle_cli_indication_add’,
>     inlined from ‘handle_cli_indication_add’ at indications.c:658:14:
> indications.c:705:3: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
>   705 |   ast_log(LOG_WARNING, "Unable to register indication %s/%s\n", a->argv[2], a->argv[3]);
>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{code}On default, Asterisk compiles with [optimization level|http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html] 3. This warning does not happen with DONT_OPTIMIZE, which is level 0, which we developers use normally. Actually, GCC sees that argv\[3\] might be NULL when logging this warning. And NULL is not a good value for built-in functions, [see…|http://stackoverflow.com/q/11589342]
> While debugging this GCC warning, I changed {{ast_strlen_zero()}} in the file {{include/strings.h}} to return just {{return (!s);}}. That revealed another four places in code which are called with a NULL value always:{code}In function ‘add_calltoken_ignore’,
>     inlined from ‘set_config’ at chan_iax2.c:13817:8:
> chan_iax2.c:2803:3: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
>  2803 |   ast_log(LOG_WARNING, "invalid calltokenoptional %s\n", addr);
>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In function ‘proc_422_rsp’,
>     inlined from ‘handle_response_invite’ at chan_sip.c:24453:3:
> chan_sip.c:30384:3: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
> 30384 |   ast_log(LOG_WARNING, "422 response without a Min-SE header %s\n", p_hdrval);
>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from .../include/asterisk/lock.h:63,
>                  from chan_sip.c:236:
> chan_sip.c: In function ‘handle_request_subscribe’:
> .../include/asterisk/logger.h:447:4: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
>   447 |    ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
>       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> chan_sip.c:28804:4: note: in expansion of macro ‘ast_debug’
> 28804 |    ast_debug(2, "Received SIP mailbox subscription for unknown format: %s\n", accept);
>       |    ^~~~~~~~~
> chan_sip.c:28804:72: note: format string is defined here
> 28804 |    ast_debug(2, "Received SIP mailbox subscription for unknown format: %s\n", accept);
>       |                                                                        ^~
> res_stir_shaken.c: In function ‘stir_shaken_read’:
> res_stir_shaken.c:1202:3: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
>  1202 |   ast_log(LOG_ERROR, "Retrieving a value using %s requires two paramaters (index, value) "
>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1203 |    "- only index was given (%s)\n", function, second);
>       |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> res_stir_shaken.c:1203:29: note: format string is defined here
>  1203 |    "- only index was given (%s)\n", function, second);
>       |                             ^~{code}



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



More information about the asterisk-bugs mailing list