diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-02 17:42:09 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-02 17:42:09 +0000 |
commit | 6ff615e68be78d9626180f804d5a24adf1ff98ba (patch) | |
tree | 3a18d1bf24edff9f01f9919113a39de3b3a8abe7 | |
parent | 02507c8489d2651cc89cc0316ce8bc063de3eab3 (diff) |
When the text does not match exactly (e.g. RTP/SAVP), then the %n conversion
fails, and the resulting integer is garbage. Thus, we must initialize the
integer and check it afterwards for success.
(closes issue #14000)
Reported by: folke
Patches:
asterisk-sipbg-sscanf-1.4.22.diff uploaded by folke (license 626)
asterisk-sipbg-sscanf-1.6.0.1.diff uploaded by folke (license 626)
asterisk-sipbg-sscanf-trunk-r159896.diff uploaded by folke (license 626)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@160297 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 0eb2336d1..a98afc3d9 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -5185,8 +5185,9 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) int audio = FALSE; numberofports = 1; - if ((sscanf(m, "audio %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2) || - (sscanf(m, "audio %d RTP/AVP %n", &x, &len) == 1)) { + len = -1; + if ((sscanf(m, "audio %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0) || + (sscanf(m, "audio %d RTP/AVP %n", &x, &len) == 1 && len > 0)) { audio = TRUE; numberofmediastreams++; /* Found audio stream in this media definition */ @@ -5201,8 +5202,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) ast_verbose("Found RTP audio format %d\n", codec); ast_rtp_set_m_type(newaudiortp, codec); } - } else if ((sscanf(m, "video %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2) || - (sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1)) { + } else if ((sscanf(m, "video %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0) || + (sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1 && len >= 0)) { /* If it is not audio - is it video ? */ ast_clear_flag(&p->flags[0], SIP_NOVIDEO); numberofmediastreams++; @@ -5217,8 +5218,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) ast_verbose("Found RTP video format %d\n", codec); ast_rtp_set_m_type(newvideortp, codec); } - } else if (p->udptl && ( (sscanf(m, "image %d udptl t38%n", &x, &len) == 1) || - (sscanf(m, "image %d UDPTL t38%n", &x, &len) == 1) )) { + } else if (p->udptl && ( (sscanf(m, "image %d udptl t38%n", &x, &len) == 1 && len > 0) || + (sscanf(m, "image %d UDPTL t38%n", &x, &len) == 1 && len >= 0) )) { if (debug) ast_verbose("Got T.38 offer in SDP in dialog %s\n", p->callid); udptlportno = x; |