Index: configure =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: configure.ac =================================================================== --- configure.ac (revision 245728) +++ configure.ac (working copy) @@ -619,6 +619,18 @@ AC_MSG_RESULT(no) ) +# glibc, AFAIK, is the only C library that makes printing a NULL to a string safe. +AC_MSG_CHECKING([if your system printf is NULL-safe.]) +AC_RUN_IFELSE( + AC_LANG_PROGRAM([#include ], + [printf("%s", NULL)]), + AC_DEFINE([HAVE_NULLSAFE_PRINTF], 1, [Define to 1 if your C library can safely print NULL to string formats.]) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no), + # It's unlikely an embedded system will have this. + AC_MSG_RESULT(unknown) +) + AST_GCC_ATTRIBUTE(pure) AST_GCC_ATTRIBUTE(malloc) AST_GCC_ATTRIBUTE(const) Index: include/asterisk/autoconfig.h.in =================================================================== --- include/asterisk/autoconfig.h.in (revision 245728) +++ include/asterisk/autoconfig.h.in (working copy) @@ -591,6 +591,9 @@ /* Define to 1 if you have the `ntohll' function. */ #undef HAVE_NTOHLL +/* Define to 1 if your C library can safely print NULL to string formats. */ +#undef HAVE_NULLSAFE_PRINTF + /* Define to 1 if your ODBC library has wide (Unicode) types. */ #undef HAVE_ODBC_WCHAR Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 245728) +++ res/res_agi.c (working copy) @@ -1006,7 +1006,7 @@ return NULL; } agi_commands = store->data; - AST_LIST_LOCK(agi_commands); + ST_LIST_LOCK(agi_commands); cmd = AST_LIST_REMOVE_HEAD(agi_commands, entry); AST_LIST_UNLOCK(agi_commands); return cmd; @@ -3014,16 +3014,22 @@ ast_join(fullcmd, sizeof(fullcmd), cmd->cmda); if (!find_command(cmd->cmda, 1)) { -#ifdef AST_XML_DOCS *((enum ast_doc_src *) &cmd->docsrc) = AST_STATIC_DOC; if (ast_strlen_zero(cmd->summary) && ast_strlen_zero(cmd->usage)) { +#ifdef AST_XML_DOCS *((char **) &cmd->summary) = ast_xmldoc_build_synopsis("agi", fullcmd); *((char **) &cmd->usage) = ast_xmldoc_build_description("agi", fullcmd); *((char **) &cmd->syntax) = ast_xmldoc_build_syntax("agi", fullcmd); *((char **) &cmd->seealso) = ast_xmldoc_build_seealso("agi", fullcmd); *((enum ast_doc_src *) &cmd->docsrc) = AST_XML_DOC; +#elif (!defined(HAVE_NULLSAFE_PRINTF)) + *((char **) &cmd->summary) = ast_strdup(""); + *((char **) &cmd->usage) = ast_strdup(""); + *((char **) &cmd->syntax) = ast_strdup(""); + *((char **) &cmd->seealso) = ast_strdup(""); +#endif } -#endif + cmd->mod = mod; AST_RWLIST_WRLOCK(&agi_commands); AST_LIST_INSERT_TAIL(&agi_commands, cmd, list); @@ -3266,9 +3272,13 @@ "Result: %s\r\n", chan->name, command_id, ami_cmd, resultcode, ami_res); switch(res) { case RESULT_SHOWUSAGE: - ast_agi_send(agi->fd, chan, "520-Invalid command syntax. Proper usage follows:\n"); - ast_agi_send(agi->fd, chan, "%s", c->usage); - ast_agi_send(agi->fd, chan, "520 End of proper usage.\n"); + if (ast_strlen_zero(c->usage)) { + ast_agi_send(agi->fd, chan, "520 Invalid command syntax. Proper usage not available.\n"); + } else { + ast_agi_send(agi->fd, chan, "520-Invalid command syntax. Proper usage follows:\n"); + ast_agi_send(agi->fd, chan, "%s", c->usage); + ast_agi_send(agi->fd, chan, "520 End of proper usage.\n"); + } break; case RESULT_FAILURE: /* They've already given the failure. We've been hung up on so handle this