[asterisk-commits] oej: branch 1.4 r114890 - /branches/1.4/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 30 11:23:18 CDT 2008


Author: oej
Date: Wed Apr 30 11:23:17 2008
New Revision: 114890

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114890
Log:
Don't crash on bad SIP replys.
Fix created in Huntsville together with Mark M (putnopvut)

(closes issue #12363)
Reported by: jvandal
Tested by: putnopvut, oej

Modified:
    branches/1.4/channels/chan_sip.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=114890&r1=114889&r2=114890
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Wed Apr 30 11:23:17 2008
@@ -1460,7 +1460,7 @@
 static void set_insecure_flags(struct ast_flags *flags, const char *value, int lineno);
 static int find_sip_method(const char *msg);
 static unsigned int parse_sip_options(struct sip_pvt *pvt, const char *supported);
-static void parse_request(struct sip_request *req);
+static int parse_request(struct sip_request *req);
 static const char *get_header(const struct sip_request *req, const char *name);
 static char *referstatus2str(enum referstatus rstatus) attribute_pure;
 static int method_match(enum sipmethod id, const char *name);
@@ -4811,7 +4811,7 @@
 /*! \brief Parse a SIP message 
 	\note this function is used both on incoming and outgoing packets
 */
-static void parse_request(struct sip_request *req)
+static int parse_request(struct sip_request *req)
 {
 	/* Divide fields by NULL's */
 	char *c;
@@ -4878,7 +4878,7 @@
 	if (*c) 
 		ast_log(LOG_WARNING, "Odd content, extra stuff left over ('%s')\n", c);
 	/* Split up the first line parts */
-	determine_firstline_parts(req);
+	return determine_firstline_parts(req);
 }
 
 /*!
@@ -15497,7 +15497,9 @@
 	if (ast_test_flag(&req, SIP_PKT_DEBUG))
 		ast_verbose("\n<--- SIP read from %s:%d --->\n%s\n<------------->\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), req.data);
 
-	parse_request(&req);
+	if(parse_request(&req) == -1) /* Bad packet, can't parse */
+		return 1;
+
 	req.method = find_sip_method(req.rlPart1);
 
 	if (ast_test_flag(&req, SIP_PKT_DEBUG))




More information about the asterisk-commits mailing list