diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-11-23 15:09:24 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-11-23 15:09:24 +0000 |
commit | b663a8e7f7bfac4ab49e995d2ffedf7d3edc639e (patch) | |
tree | d8dda4f18fb7b85ef6ca5f761e2c641142179fc1 /channels | |
parent | f03ce510ecc387c452ed94ebf4e5f81b7f191819 (diff) |
Correct fix for issue #16268... the reporter's original patch was very close to correct.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@230839 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 52ce80a6d..0df521211 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -636,7 +636,7 @@ struct sip_request { char *line[SIP_MAX_LINES]; char data[SIP_MAX_PACKET]; unsigned int sdp_start; /*!< the line number where the SDP begins */ - unsigned int sdp_end; /*!< the line number where the SDP ends */ + unsigned int sdp_count; /*!< the number of lines of SDP */ AST_LIST_ENTRY(sip_request) next; }; @@ -4367,26 +4367,31 @@ static const char *get_sdp_iterate(int *start, struct sip_request *req, const ch { int len = strlen(name); - while (*start <= req->sdp_end) { + while (*start < (req->sdp_start + req->sdp_count)) { const char *r = get_body_by_line(req->line[(*start)++], name, len); if (r[0] != '\0') return r; } + /* if the line was not found, ensure that *start points past the SDP */ + (*start)++; + return ""; } /*! \brief Fetches the next valid SDP line between the 'start' line - * and the 'stop' line (*excluding* the 'stop' line). Returns the type - * ('a', 'c', ...) and matching line in reference 'start' is updated with the - * next line number. + * (inclusive) and the 'stop' line (exclusive). Returns the type + * ('a', 'c', ...) and matching line in reference 'start' is updated + * with the next line number. */ static char get_sdp_line(int *start, int stop, struct sip_request *req, const char **value) { char type = '\0'; const char *line = NULL; - if (stop > req->sdp_end || stop < req->sdp_start) stop = req->sdp_end + 1; + if (stop > (req->sdp_start + req->sdp_count)) { + stop = req->sdp_start + req->sdp_count; + } while (*start < stop) { line = req->line[(*start)++]; @@ -5121,7 +5126,7 @@ static int parse_request(struct sip_request *req) \param req the SIP request to process \return 1 if SDP found, 0 if not found - Also updates req->sdp_start and req->sdp_end to indicate where the SDP + Also updates req->sdp_start and req->sdp_count to indicate where the SDP lives in the message body. */ static int find_sdp(struct sip_request *req) @@ -5154,7 +5159,7 @@ static int find_sdp(struct sip_request *req) /* if the body contains only SDP, this is easy */ if (!strncasecmp(content_type, "application/sdp", 15)) { req->sdp_start = 0; - req->sdp_end = req->lines; + req->sdp_count = req->lines; return req->lines ? 1 : 0; } @@ -5193,7 +5198,7 @@ static int find_sdp(struct sip_request *req) for (x = 0; x < (req->lines ); x++) { if(!strncasecmp(req->line[x], boundary, strlen(boundary))){ if(found_application_sdp && found_end_of_headers){ - req->sdp_end = x-1; + req->sdp_count = (x - 1) - req->sdp_start; return 1; } found_application_sdp = FALSE; @@ -5209,7 +5214,7 @@ static int find_sdp(struct sip_request *req) } } if(found_application_sdp && found_end_of_headers) { - req->sdp_end = x; + req->sdp_count = x - req->sdp_start; return TRUE; } return FALSE; |