[asterisk-commits] tilghman: branch 1.6.0 r166697 - in /branches/1.6.0: ./ channels/ include/ast...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 23 14:52:20 CST 2008


Author: tilghman
Date: Tue Dec 23 14:52:19 2008
New Revision: 166697

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

........
  r166696 | tilghman | 2008-12-23 14:47:08 -0600 (Tue, 23 Dec 2008) | 7 lines
  
  Allow semicolons and extended characters in user-specified SIP headers.
  (closes issue #14110)
   Reported by: gork
   Patches: 
         20081222__bug14110__2.diff.txt uploaded by Corydon76 (license 14)
   Tested by: gork, putnopvut
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/channels/chan_sip.c
    branches/1.6.0/include/asterisk/app.h
    branches/1.6.0/main/app.c

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

Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=166697&r1=166696&r2=166697
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Tue Dec 23 14:52:19 2008
@@ -22008,7 +22008,7 @@
 	int no = 0;
 	int ok = FALSE;
 	char varbuf[30];
-	char *inbuf = data;
+	char *inbuf = data, *subbuf;
 	
 	if (ast_strlen_zero(inbuf)) {
 		ast_log(LOG_WARNING, "This application requires the argument: Header\n");
@@ -22022,13 +22022,18 @@
 		snprintf(varbuf, sizeof(varbuf), "__SIPADDHEADER%.2d", no);
 
 		/* Compare without the leading underscores */
-		if( (pbx_builtin_getvar_helper(chan, (const char *) varbuf + 2) == (const char *) NULL) )
+		if ((pbx_builtin_getvar_helper(chan, (const char *) varbuf + 2) == (const char *) NULL)) {
 			ok = TRUE;
+		}
 	}
 	if (ok) {
-		pbx_builtin_setvar_helper (chan, varbuf, inbuf);
-		if (sipdebug)
+		size_t len = strlen(inbuf);
+		subbuf = alloca(len + 1);
+		ast_get_encoded_str(inbuf, subbuf, len + 1);
+		pbx_builtin_setvar_helper(chan, varbuf, subbuf);
+		if (sipdebug) {
 			ast_debug(1, "SIP Header added \"%s\" as %s\n", inbuf, varbuf);
+		}
 	} else {
 		ast_log(LOG_WARNING, "Too many SIP headers added, max 50\n");
 	}

Modified: branches/1.6.0/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk/app.h?view=diff&rev=166697&r1=166696&r2=166697
==============================================================================
--- branches/1.6.0/include/asterisk/app.h (original)
+++ branches/1.6.0/include/asterisk/app.h Tue Dec 23 14:52:19 2008
@@ -480,6 +480,9 @@
 /*! \brief Decode an encoded control or extended ASCII character */
 int ast_get_encoded_char(const char *stream, char *result, size_t *consumed);
 
+/*! \brief Decode a string which may contain multiple encoded control or extended ASCII characters */
+int ast_get_encoded_str(const char *stream, char *result, size_t result_size);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: branches/1.6.0/main/app.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/app.c?view=diff&rev=166697&r1=166696&r2=166697
==============================================================================
--- branches/1.6.0/main/app.c (original)
+++ branches/1.6.0/main/app.c Tue Dec 23 14:52:19 2008
@@ -1775,3 +1775,16 @@
 	return 0;
 }
 
+int ast_get_encoded_str(const char *stream, char *result, size_t result_size)
+{
+	char *cur = result;
+	size_t consumed;
+
+	while (cur < result + result_size - 1 && !ast_get_encoded_char(stream, cur, &consumed)) {
+		cur++;
+		stream += consumed;
+	}
+	*cur = '\0';
+	return 0;
+}
+




More information about the asterisk-commits mailing list