[asterisk-commits] rizzo: branch rizzo/astobj2 r47247 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Nov 7 04:49:17 MST 2006


Author: rizzo
Date: Tue Nov  7 05:49:16 2006
New Revision: 47247

URL: http://svn.digium.com/view/asterisk?rev=47247&view=rev
Log:
Note a dubious set of checks for authpeer == NULL,
which needs to be revisited.

Just in case (and for consistency with surrounding code),
prevent dereferencing a NULL pointer.

Trunk candidate, though i don't believe that authpeer
can be NULL there. But better safe than sorry.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?rev=47247&r1=47246&r2=47247&view=diff
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Nov  7 05:49:16 2006
@@ -14222,6 +14222,11 @@
 		return 0;
 	}
 
+	/* \todo At this point, i believe (but not 100% sure) that
+	 * authpeer cannot be NULL. If that is the case, we should remove
+	 * all those checks for authpeer == NULL as they reduce readability.
+	 */
+
 	/* Check if this user/peer is allowed to subscribe at all */
 	if (!ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
 		transmit_response(p, "403 Forbidden (policy)", req);
@@ -14301,7 +14306,8 @@
 		if (!authpeer || ast_strlen_zero(authpeer->mailbox)) {
 			transmit_response(p, "404 Not found (no mailbox)", req);
 			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
-			ast_log(LOG_NOTICE, "Received SIP subscribe for peer without mailbox: %s\n", authpeer->name);
+			ast_log(LOG_NOTICE, "Received SIP subscribe for peer without mailbox: %s\n",
+				authpeer ? authpeer->name : "(no peer)");
 			if (authpeer)
 				unref_peer(authpeer);
 			return 0;



More information about the asterisk-commits mailing list