[asterisk-commits] rizzo: trunk r45009 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Oct 13 04:11:20 MST 2006


Author: rizzo
Date: Fri Oct 13 06:11:19 2006
New Revision: 45009

URL: http://svn.digium.com/view/asterisk?rev=45009&view=rev
Log:
arguments to auth_headers() needed to be swapped here.
To avoid the same mistake in the future (due to slightly
confusing variable names), add a comment.

On passing, remove a redundant initialization.


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=45009&r1=45008&r2=45009&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Oct 13 06:11:19 2006
@@ -7737,7 +7737,7 @@
 					 const char *secret, const char *md5secret, int sipmethod,
 					 char *uri, enum xmittype reliable, int ignore)
 {
-	const char *response = "407 Proxy Authentication Required";
+	const char *response;
 	char *reqheader, *respheader;
 	const char *authtoken;
 	char a1_hash[256];
@@ -7746,6 +7746,7 @@
 	char *c;
 	int  wrongnonce = FALSE;
 	int  good_response;
+	int code;
 	const char *usednonce = p->randdata;
 
 	/* table of recognised keywords, and their value in the digest */
@@ -7768,12 +7769,18 @@
 		/* On a REGISTER, we have to use 401 and its family of headers
 		 * instead of 407 and its family of headers.
 		 */
+		code = WWW_AUTH;
 		response = "401 Unauthorized";
-		auth_headers(WWW_AUTH, &reqheader, &respheader);
 	} else {
+		code = PROXY_AUTH;
 		response = "407 Proxy Authentication Required";
-		auth_headers(PROXY_AUTH, &reqheader, &respheader);
-	}
+	}
+	/*
+	 * Note the apparent swap of arguments below, compared to other
+	 * usages of auth_headers().
+	 */
+	auth_headers(code, &respheader, &reqheader);
+
 	authtoken =  get_header(req, reqheader);	
 	if (ignore && !ast_strlen_zero(p->randdata) && ast_strlen_zero(authtoken)) {
 		/* This is a retransmitted invite/register/etc, don't reconstruct authentication



More information about the asterisk-commits mailing list