summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-01-29 14:48:28 +0000
committerMatthew Jordan <mjordan@digium.com>2013-01-29 14:48:28 +0000
commit126060042ed39993576948e437ea82b8de183de7 (patch)
tree1d38f9140e445e3b51cc5c50aa77b183dda40d72 /channels
parent148b6e7fba1d5061bf59b712b72d83cc8d85dd69 (diff)
Ensure that a declined media stream is terminated with a '\r\n'
In r369028, chan_sip's processing of media streams in an SDP was modified to better handle multiple offered media streams. Part of that change modified how streams were declined. Previously, declined media streams were not handled in an RFC compliant manner; now, we set the port number to 0 in the media stream definition and proceed on with the next media stream. Unfortunately, the formatting of the declined media stream forgot to append a '\r\n' to the end of the media stream. This is normally added to the accepted media streams later on in the processing of the SDP. Since the declined media stream uses a different buffer than the accepted media streams (and is a malloc'd buffer as opposed to a struct ast_str), it's easier to just slap the '\r\n' on the declined media stream buffer rather than attempt to append it later on. So, that's what we do. And now some devices (and probably some providers) will be a bit happier (but probably not terribly happy, since we just rejected something they offered). Review: https://reviewboard.asterisk.org/r/2297/ (closes issue ASTERISK-20908) Reported by: Dennis DeDonatis Tested by: Dennis DeDonatis ........ Merged revisions 380331 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380332 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 86009f927..6f046b58c 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10100,14 +10100,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
(sscanf(m, "audio %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
codecs = m + len;
/* produce zero-port m-line since it may be needed later
- * length is "m=audio 0 " + protocol + " " + codecs + "\0" */
- if (!(offer->decline_m_line = ast_malloc(10 + strlen(protocol) + 1 + strlen(codecs) + 1))) {
+ * length is "m=audio 0 " + protocol + " " + codecs + "\r\n\0" */
+ if (!(offer->decline_m_line = ast_malloc(10 + strlen(protocol) + 1 + strlen(codecs) + 3))) {
ast_log(LOG_WARNING, "Failed to allocate memory for SDP offer declination\n");
res = -1;
goto process_sdp_cleanup;
}
/* guaranteed to be exactly the right length */
- sprintf(offer->decline_m_line, "m=audio 0 %s %s", protocol, codecs);
+ sprintf(offer->decline_m_line, "m=audio 0 %s %s\r\n", protocol, codecs);
if (x == 0) {
ast_debug(1, "Ignoring audio media offer because port number is zero\n");
@@ -10182,14 +10182,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
(sscanf(m, "video %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
codecs = m + len;
/* produce zero-port m-line since it may be needed later
- * length is "m=video 0 " + protocol + " " + codecs + "\0" */
- if (!(offer->decline_m_line = ast_malloc(10 + strlen(protocol) + 1 + strlen(codecs) + 1))) {
+ * length is "m=video 0 " + protocol + " " + codecs + "\r\n\0" */
+ if (!(offer->decline_m_line = ast_malloc(10 + strlen(protocol) + 1 + strlen(codecs) + 3))) {
ast_log(LOG_WARNING, "Failed to allocate memory for SDP offer declination\n");
res = -1;
goto process_sdp_cleanup;
}
/* guaranteed to be exactly the right length */
- sprintf(offer->decline_m_line, "m=video 0 %s %s", protocol, codecs);
+ sprintf(offer->decline_m_line, "m=video 0 %s %s\r\n", protocol, codecs);
if (x == 0) {
ast_debug(1, "Ignoring video stream offer because port number is zero\n");
@@ -10260,14 +10260,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
(sscanf(m, "text %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
codecs = m + len;
/* produce zero-port m-line since it may be needed later
- * length is "m=text 0 " + protocol + " " + codecs + "\0" */
- if (!(offer->decline_m_line = ast_malloc(9 + strlen(protocol) + 1 + strlen(codecs) + 1))) {
+ * length is "m=text 0 " + protocol + " " + codecs + "\r\n\0" */
+ if (!(offer->decline_m_line = ast_malloc(9 + strlen(protocol) + 1 + strlen(codecs) + 3))) {
ast_log(LOG_WARNING, "Failed to allocate memory for SDP offer declination\n");
res = -1;
goto process_sdp_cleanup;
}
/* guaranteed to be exactly the right length */
- sprintf(offer->decline_m_line, "m=text 0 %s %s", protocol, codecs);
+ sprintf(offer->decline_m_line, "m=text 0 %s %s\r\n", protocol, codecs);
if (x == 0) {
ast_debug(1, "Ignoring text stream offer because port number is zero\n");
@@ -10323,14 +10323,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if (((sscanf(m, "image %30u udptl t38%n", &x, &len) == 1 && len > 0) ||
(sscanf(m, "image %30u UDPTL t38%n", &x, &len) == 1 && len > 0))) {
/* produce zero-port m-line since it may be needed later
- * length is "m=image 0 udptl t38" + "\0" */
- if (!(offer->decline_m_line = ast_malloc(20))) {
+ * length is "m=image 0 udptl t38" + "\r\n\0" */
+ if (!(offer->decline_m_line = ast_malloc(22))) {
ast_log(LOG_WARNING, "Failed to allocate memory for SDP offer declination\n");
res = -1;
goto process_sdp_cleanup;
}
/* guaranteed to be exactly the right length */
- strcpy(offer->decline_m_line, "m=image 0 udptl t38");
+ strcpy(offer->decline_m_line, "m=image 0 udptl t38\r\n");
if (x == 0) {
ast_debug(1, "Ignoring image stream offer because port number is zero\n");
@@ -10372,14 +10372,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if ((sscanf(m, "%19s %30u/%30u %n", type, &x, &numberofports, &len) == 3 && len > 0) ||
(sscanf(m, "%19s %30u %n", type, &x, &len) == 2 && len > 0)) {
/* produce zero-port m-line since it may be needed later
- * length is "m=" + type + " 0 " + remainder + "\0" */
- if (!(offer->decline_m_line = ast_malloc(2 + strlen(type) + 3 + strlen(m + len) + 1))) {
+ * length is "m=" + type + " 0 " + remainder + "\r\n\0" */
+ if (!(offer->decline_m_line = ast_malloc(2 + strlen(type) + 3 + strlen(m + len) + 3))) {
ast_log(LOG_WARNING, "Failed to allocate memory for SDP offer declination\n");
res = -1;
goto process_sdp_cleanup;
}
/* guaranteed to be long enough */
- sprintf(offer->decline_m_line, "m=%s 0 %s", type, m + len);
+ sprintf(offer->decline_m_line, "m=%s 0 %s\r\n", type, m + len);
continue;
} else {
ast_log(LOG_WARNING, "Unsupported top-level media type in offer: %s\n", m);