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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 29 15:44:10 CDT 2010


Author: dvossel
Date: Tue Jun 29 15:44:05 2010
New Revision: 272981

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=272981
Log:
send a 400 Bad Request on malformed sip request

RFC 2361 section 24.4.1 send a 400 Bad Request if the request
can not be understood due to malformed syntax.  Currently we
simply ignore a packet with a missing callid, to, from, or
via header.  Instead of ignoring we now send the 400 Bad request.

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=272981&r1=272980&r2=272981
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Jun 29 15:44:05 2010
@@ -7002,8 +7002,14 @@
 	/* Call-ID, to, from and Cseq are required by RFC 3261. (Max-forwards and via too - ignored now) */
 	/* get_header always returns non-NULL so we must use ast_strlen_zero() */
 	if (ast_strlen_zero(callid) || ast_strlen_zero(to) ||
-			ast_strlen_zero(from) || ast_strlen_zero(cseq))
+			ast_strlen_zero(from) || ast_strlen_zero(cseq)) {
+
+		/* RFC 3261 section 24.4.1.   Send a 400 Bad Request if the request is malformed. */
+		if (intended_method != SIP_RESPONSE && intended_method != SIP_ACK) {
+			transmit_response_using_temp(callid, sin, 1, intended_method, req, "400 Bad Request");
+		}
 		return NULL;	/* Invalid packet */
+	}
 
 	if (sip_cfg.pedanticsipchecking) {
 		/* In principle Call-ID's uniquely identify a call, but with a forking SIP proxy




More information about the asterisk-commits mailing list