summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2009-11-23 15:34:16 +0000
committerKevin P. Fleming <kpfleming@digium.com>2009-11-23 15:34:16 +0000
commitfe1ebc8d46c21621bf8a09fd816f25e345d8b5b6 (patch)
treee80db07aaf5da92af3f94c6bfc27ce3ee17a2bec /channels/chan_sip.c
parent9d0319f88fcefd07b85cf394eb648e92fbca36cd (diff)
Merged revisions 230839 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r230839 | kpfleming | 2009-11-23 09:09:24 -0600 (Mon, 23 Nov 2009) | 1 line Correct fix for issue #16268... the reporter's original patch was very close to correct. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@230877 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index fb0c939cf..f36f05036 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1345,7 +1345,7 @@ struct sip_request {
int method; /*!< Method of this request */
int lines; /*!< Body Content */
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 */
char debug; /*!< print extra debugging if non zero */
char has_to_tag; /*!< non-zero if packet has To: tag */
char ignore; /*!< if non-zero This is a re-transmit, ignore it */
@@ -7113,26 +7113,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_OFFSET_TO_STR(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_OFFSET_TO_STR(req, line[(*start)++]);
@@ -8203,7 +8208,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)
@@ -8236,7 +8241,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;
}
@@ -8276,7 +8281,7 @@ static int find_sdp(struct sip_request *req)
const char *line = REQ_OFFSET_TO_STR(req, line[x]);
if (!strncasecmp(line, 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;
@@ -8292,7 +8297,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;