aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-29 20:44:05 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-29 20:44:05 +0000
commit8420f14a527c61144f1b53bdce57bc919ac2bb4c (patch)
tree7d63d3c242790615706f0aa3382f8c95c811bb0c /channels
parentdb212ff9112321b89765d1d3f64df399e7a8edbc (diff)
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. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@272981 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 18d40cc21..a87909de1 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -7002,8 +7002,14 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
/* 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