From: Tilghman Lesher Date: Tue, 23 Dec 2008 20:47:08 +0000 (+0000) Subject: Allow semicolons and extended characters in user-specified SIP headers. X-Git-Tag: 1.6.2.0-beta1~518 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c2030b489f828dec6f7a991b701fb066f7e71f2;p=thirdparty%2Fasterisk.git 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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@166696 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 87533cdba5..559b1596ba 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -23616,7 +23616,7 @@ static int sip_addheader(struct ast_channel *chan, void *data) 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"); @@ -23630,13 +23630,18 @@ static int sip_addheader(struct ast_channel *chan, void *data) 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"); }