[asterisk-commits] dvossel: trunk r213635 - /trunk/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 21 16:02:55 CDT 2009


Author: dvossel
Date: Fri Aug 21 16:02:50 2009
New Revision: 213635

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213635
Log:
fixes sip register parsing when user at domain is used

(issue #15008)
(issue #15672)

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=213635&r1=213634&r2=213635
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Aug 21 16:02:50 2009
@@ -7343,12 +7343,9 @@
 	char buf[256] = "";
 	char *username = NULL;
 	char *tmp = NULL, *transport_str = NULL;
+	char *userpart = NULL, *hostpart = NULL;
 	char *peername = NULL;
 	/* register => [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry] */
-	AST_DECLARE_APP_ARGS(parts,
-		AST_APP_ARG(userpart);
-		AST_APP_ARG(hostpart);
-	);
 	AST_DECLARE_APP_ARGS(user1,
 		AST_APP_ARG(userpart);
 		AST_APP_ARG(secret);
@@ -7377,17 +7374,26 @@
 
 	/*! register => [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry]
 	 * becomes
-	 *   parts.userpart => [peer?][transport://]user[@domain][:secret[:authuser]]
-	 *   parts.hostpart => host[:port][/extension][~expiry]
+	 *   userpart => [peer?][transport://]user[@domain][:secret[:authuser]]
+	 *   hostpart => host[:port][/extension][~expiry]
 	 */
-	AST_NONSTANDARD_RAW_ARGS(parts, buf, '@');
+	if ((hostpart = strrchr(buf, '@'))) {
+		*hostpart++ = '\0';
+		userpart = buf;
+	}
+
+	if (ast_strlen_zero(userpart) || ast_strlen_zero(hostpart)) {
+		ast_log(LOG_WARNING, "Format for registration is [transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry] at line %d\n", lineno);
+		return -1;
+	}
+
 	/*!
 	 * user1.userpart => [peer?][transport://]user[@domain]
 	 * user1.secret => secret
 	 * user1.authuser => authuser
-	 * parts.hostpart => host[:port][/extension][~expiry]
+	 * hostpart => host[:port][/extension][~expiry]
 	 */
-	AST_NONSTANDARD_RAW_ARGS(user1, parts.userpart, ':');
+	AST_NONSTANDARD_RAW_ARGS(user1, userpart, ':');
 
 	/*!
 	 * user1.userpart => [peer?][transport://]user[@domain]
@@ -7396,7 +7402,7 @@
 	 * host1.hostpart => host[:port][/extension]
 	 * host1.expiry => [expiry]
 	 */
-	AST_NONSTANDARD_RAW_ARGS(host1, parts.hostpart, '~');
+	AST_NONSTANDARD_RAW_ARGS(host1, hostpart, '~');
 
 	/*!
 	 * user1.userpart => [peer?][transport://]user[@domain]
@@ -7406,7 +7412,7 @@
 	 * host2.extension => [extension]
 	 * host1.expiry => [expiry]
 	 */
-	AST_NONSTANDARD_RAW_ARGS(host2, parts.hostpart, '/');
+	AST_NONSTANDARD_RAW_ARGS(host2, hostpart, '/');
 
 	/*!
 	 * user1.userpart => [peer?][transport://]user[@domain]
@@ -7417,7 +7423,18 @@
 	 * host2.extension => extension
 	 * host1.expiry => expiry
 	 */
-	AST_NONSTANDARD_RAW_ARGS(host3, parts.hostpart, ':');
+	AST_NONSTANDARD_RAW_ARGS(host3, hostpart, ':');
+
+	/*!
+	 * user2.userpart => [peer?][transport://]user[@domain]
+	 * user1.secret => secret
+	 * user1.authuser => authuser
+	 * host3.host => host
+	 * host3.port => port
+	 * host2.extension => extension (callback)
+	 * host1.expiry => expiry
+	 */
+	AST_NONSTANDARD_RAW_ARGS(user2, user1.userpart, ':');
 
 	/*!
 	 * user2.userpart => [peer?][transport://]user
@@ -7429,7 +7446,7 @@
 	 * host2.extension => extension (callback)
 	 * host1.expiry => expiry
 	 */
-	AST_NONSTANDARD_RAW_ARGS(user2, user1.userpart, ':');
+	AST_NONSTANDARD_RAW_ARGS(user2, user2.userpart, '@');
 
 	if ((tmp = strchr(user2.userpart, '?'))) {
 		*tmp = '\0';




More information about the asterisk-commits mailing list