[asterisk-commits] dvossel: trunk r271553 - in /trunk/channels: chan_sip.c sip/reqresp_parser.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jun 21 15:46:27 CDT 2010
Author: dvossel
Date: Mon Jun 21 15:46:22 2010
New Revision: 271553
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=271553
Log:
fixes crash when From header URI is missing "sip:"
(closes issue #17437)
Reported by: klaus3000
Patches:
sip_crash uploaded by dvossel (license 671)
Tested by: klaus3000
Modified:
trunk/channels/chan_sip.c
trunk/channels/sip/reqresp_parser.c
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=271553&r1=271552&r2=271553
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Jun 21 15:46:22 2010
@@ -14445,8 +14445,8 @@
struct sockaddr_in *sin, struct sip_peer **authpeer)
{
char from[256] = { 0, };
- char *dummy; /* dummy return value for parse_uri */
- char *domain; /* dummy return value for parse_uri */
+ char *dummy = NULL; /* dummy return value for parse_uri */
+ char *domain = NULL; /* dummy return value for parse_uri */
char *of;
enum check_auth_result res = AUTH_DONT_KNOW;
char calleridname[50];
Modified: trunk/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/reqresp_parser.c?view=diff&rev=271553&r1=271552&r2=271553
==============================================================================
--- trunk/channels/sip/reqresp_parser.c (original)
+++ trunk/channels/sip/reqresp_parser.c Mon Jun 21 15:46:22 2010
@@ -759,6 +759,11 @@
}
}
+ if (*input != '<') { /* if we never found the start of addr-spec then this is invalid */
+ *orig_output = '\0';
+ return orig_input;
+ }
+
/* set NULL while trimming trailing whitespace */
do {
*output-- = '\0';
@@ -776,6 +781,7 @@
const char *overflow1 = " \"quoted-text overflow 1234567890123456789012345678901234567890\" <stuff>";
const char *noendquote = " \"quoted-text no end <stuff>";
const char *addrspec = " \"sip:blah at blah <stuff>";
+ const char *no_quotes_no_brackets = "blah at blah";
const char *after_dname;
char dname[40];
@@ -829,6 +835,15 @@
ast_test_status_update(test, "detection of addr-spec failed\n");
res = AST_TEST_FAIL;
}
+
+ /* no quotes, no brackets */
+ after_dname = get_calleridname(no_quotes_no_brackets, dname, sizeof(dname));
+ ast_test_status_update(test, "no_quotes_no_brackets display-name1: %s\nafter: %s\n", dname, after_dname);
+ if (*dname != '\0' && after_dname != no_quotes_no_brackets) {
+ ast_test_status_update(test, "detection of addr-spec failed\n");
+ res = AST_TEST_FAIL;
+ }
+
return res;
}
@@ -1065,6 +1080,7 @@
char missing_end_quote[] = "\"I'm a quote string <sip:name:secret at host:port;transport=tcp?headers=testblah&headers2=blahblah>";
char name_no_quotes[] = "name not in quotes <sip:name:secret at host:port;transport=tcp?headers=testblah&headers2=blahblah>";
char no_end_bracket[] = "name not in quotes <sip:name:secret at host:port;transport=tcp?headers=testblah&headers2=blahblah";
+ char no_name_no_brackets[] = "sip:name at host";
char *uri = NULL;
switch (cmd) {
@@ -1122,6 +1138,12 @@
res = AST_TEST_FAIL;
}
+ /* Test 7, no name, and no brackets. */
+ if (!(uri = get_in_brackets(no_name_no_brackets)) || (strcmp(uri, "sip:name at host"))) {
+
+ ast_test_status_update(test, "Test 7 failed. %s\n", uri);
+ res = AST_TEST_FAIL;
+ }
return res;
}
More information about the asterisk-commits
mailing list