aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-30 16:23:17 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-30 16:23:17 +0000
commit1f38b7ffa6d9bf56334911a3af8ea590c6832d1a (patch)
tree18f14c9ff3ccb54a5c2b88b9addb4b1ea1854835
parentdfa80fc343e382e99e91304e9a058d582eaa841e (diff)
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 git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@114890 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index e3fab9232..8bf290a63 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1460,7 +1460,7 @@ static const char *gettag(const struct sip_request *req, const char *header, cha
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 @@ static int lws2sws(char *msgbuf, int len)
/*! \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 @@ static void parse_request(struct sip_request *req)
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 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
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))