[svn-commits] jpeeler: branch 1.8 r297607 - in /branches/1.8: ./ channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 6 16:06:41 CST 2010


Author: jpeeler
Date: Mon Dec  6 16:06:37 2010
New Revision: 297607

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=297607
Log:
Merged revisions 297605 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
  r297605 | jpeeler | 2010-12-06 16:03:04 -0600 (Mon, 06 Dec 2010) | 18 lines
  
  Merged revisions 297603 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r297603 | jpeeler | 2010-12-06 15:57:15 -0600 (Mon, 06 Dec 2010) | 12 lines
    
    Improve handling of REGISTER requests with multiple contact headers.
    
    The changes here attempt to more strictly follow RFC 3261 section 10.3.
    Basically the following will now cause a 400 Bad Response to be returned, if:
    - multiple Contact headers are present with one set to expire all bindings ("*")
    - wildcard parameter is specified for Contact without Expires header or Expires
      header is not set to zero.
    
    ABE-2442
    ABE-2443
  ........
................

Modified:
    branches/1.8/   (props changed)
    branches/1.8/channels/chan_sip.c

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

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=297607&r1=297606&r2=297607
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Mon Dec  6 16:06:37 2010
@@ -12969,8 +12969,12 @@
 	int transport_type;
 	const char *useragent;
 	struct ast_sockaddr oldsin, testsa;
-
-	ast_copy_string(contact, get_header(req, "Contact"), sizeof(contact));
+	char *firstcuri = NULL;
+	int start = 0;
+	int wildcard_found = 0;
+	int single_binding_found;
+
+	ast_copy_string(contact, __get_header(req, "Contact", &start), sizeof(contact));
 
 	if (ast_strlen_zero(expires)) {	/* No expires header, try look in Contact: */
 		char *s = strcasestr(contact, ";expires=");
@@ -12987,11 +12991,31 @@
 
 	copy_socket_data(&pvt->socket, &req->socket);
 
-	/* Look for brackets */
-	curi = contact;
-	if (strchr(contact, '<') == NULL)	/* No <, check for ; and strip it */
-		strsep(&curi, ";");	/* This is Header options, not URI options */
-	curi = get_in_brackets(contact);
+	do {
+		/* Look for brackets */
+		curi = contact;
+		if (strchr(contact, '<') == NULL)	/* No <, check for ; and strip it */
+			strsep(&curi, ";");	/* This is Header options, not URI options */
+		curi = get_in_brackets(contact);
+		if (!firstcuri) {
+			firstcuri = ast_strdupa(curi);
+		}
+
+		if (!strcasecmp(curi, "*")) {
+			wildcard_found = 1;
+		} else {
+			single_binding_found = 1;
+		}
+
+		if (wildcard_found && (ast_strlen_zero(expires) || expire != 0 || single_binding_found)) {
+			/* Contact header parameter "*" detected, so punt if: Expires header is missing,
+			 * Expires value is not zero, or another Contact header is present. */
+			return PARSE_REGISTER_FAILED;
+		}
+
+		ast_copy_string(contact, __get_header(req, "Contact", &start), sizeof(contact));
+	} while (!ast_strlen_zero(contact));
+	curi = firstcuri;
 
 	/* if they did not specify Contact: or Expires:, they are querying
 	   what we currently have stored as their contact address, so return




More information about the svn-commits mailing list