[asterisk-commits] tilghman: branch 1.6.2 r246199 - in /branches/1.6.2: ./ include/asterisk/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 10 13:49:22 CST 2010


Author: tilghman
Date: Wed Feb 10 13:49:18 2010
New Revision: 246199

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=246199
Log:
Merged revisions 246030 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r246030 | tilghman | 2010-02-10 10:01:28 -0600 (Wed, 10 Feb 2010) | 12 lines
  
  Solaris doesn't like outputting a NULL to a %s in format strings.
  
  Detect all platforms that don't like that, either, and ensure that when documentation is
  missing, we pass a non-NULL pointer when outputting the corresponding documentation.
  
  (closes issue #16689)
   Reported by: bklang
   Patches: 
         20100209__issue16689__with_tests.diff.txt uploaded by tilghman (license 14)
   
  Review: https://reviewboard.asterisk.org/r/497/
........

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/configure
    branches/1.6.2/configure.ac
    branches/1.6.2/include/asterisk/autoconfig.h.in
    branches/1.6.2/res/res_agi.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/configure.ac
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/configure.ac?view=diff&rev=246199&r1=246198&r2=246199
==============================================================================
--- branches/1.6.2/configure.ac (original)
+++ branches/1.6.2/configure.ac Wed Feb 10 13:49:18 2010
@@ -587,6 +587,18 @@
 AC_MSG_RESULT(yes)
 AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]),
 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 <stdio.h>],
+		[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)

Modified: branches/1.6.2/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/include/asterisk/autoconfig.h.in?view=diff&rev=246199&r1=246198&r2=246199
==============================================================================
--- branches/1.6.2/include/asterisk/autoconfig.h.in (original)
+++ branches/1.6.2/include/asterisk/autoconfig.h.in Wed Feb 10 13:49:18 2010
@@ -532,6 +532,9 @@
 
 /* Define to the version of the newt library. */
 #undef HAVE_NEWT_VERSION
+
+/* 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

Modified: branches/1.6.2/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/res/res_agi.c?view=diff&rev=246199&r1=246198&r2=246199
==============================================================================
--- branches/1.6.2/res/res_agi.c (original)
+++ branches/1.6.2/res/res_agi.c Wed Feb 10 13:49:18 2010
@@ -2546,7 +2546,7 @@
 		ast_join(fullcmd, sizeof(fullcmd), e->cmda);
 		if (match && strncasecmp(matchstr, fullcmd, strlen(matchstr)))
 			continue;
-		ast_cli(fd, "%5.5s %30.30s   %s\n", e->dead ? "Yes" : "No" , fullcmd, e->summary);
+		ast_cli(fd, "%5.5s %30.30s   %s\n", e->dead ? "Yes" : "No" , fullcmd, S_OR(e->summary, "Not available"));
 	}
 	AST_RWLIST_UNLOCK(&agi_commands);
 
@@ -2561,15 +2561,21 @@
 
 	if (!find_command(cmd->cmda,1)) {
 		cmd->docsrc = AST_STATIC_DOC;
+		if (ast_strlen_zero(cmd->summary) && ast_strlen_zero(cmd->usage)) {
 #ifdef AST_XML_DOCS
-		if (ast_strlen_zero(cmd->summary) && ast_strlen_zero(cmd->usage)) {
-			cmd->summary = ast_xmldoc_build_synopsis("agi", fullcmd);
-			cmd->usage = ast_xmldoc_build_description("agi", fullcmd);
-			cmd->syntax = ast_xmldoc_build_syntax("agi", fullcmd);
-			cmd->seealso = ast_xmldoc_build_seealso("agi", fullcmd);
-			cmd->docsrc = AST_XML_DOC;
-		}
+			*((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
+		}
+
 		cmd->mod = mod;
 		AST_RWLIST_WRLOCK(&agi_commands);
 		AST_LIST_INSERT_TAIL(&agi_commands, cmd, list);
@@ -2810,9 +2816,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
@@ -2993,7 +3003,7 @@
 	case CLI_INIT:
 		e->command = "agi show commands [topic]";
 		e->usage =
-			"Usage: agi show commands [topic]\n"
+			"Usage: agi show commands [topic] <topic>\n"
 			"       When called with a topic as an argument, displays usage\n"
 			"       information on the given command.  If called without a\n"
 			"       topic, it provides a list of AGI commands.\n";




More information about the asterisk-commits mailing list