santhoshpoojari14 / sipservlets

Automatically exported from code.google.com/p/sipservlets
0 stars 0 forks source link

Parentheses in CallID break SessionManagerUtil tokenizer #196

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If a Call-ID header contains right parentheses (legal according to RFC3261), 
then the sessionId derived from it will also contains right parentheses 
*inside*.

SessionManagerUtil.parseSipSessionKey() will break as the tokenizer expects a 
format "(" + text+ ")" where text is assumed to contain zero right parentheses.

Attached patch fixes the issue (just changes an indexOf() for a lastIndexOf()).

diff --git 
a/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/Session
ManagerUtil.java b/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/
index 09e5c5d..9c7dd5a 100644
--- 
a/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/Session
ManagerUtil.java
+++ 
b/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/Session
ManagerUtil.java
@@ -163,7 +163,7 @@ public class SessionManagerUtil {
                        String sipSessionKey) throws ParseException {

                int indexOfLeftParenthesis = sipSessionKey.indexOf("(");
-               int indexOfRightParenthesis = sipSessionKey.indexOf(")");
+               int indexOfRightParenthesis = sipSessionKey.lastIndexOf(")");
                if(indexOfLeftParenthesis == -1) {
                        throw new ParseException("The left parenthesis could not be found in the following key " + sipSessionKey, 0);
                }

Original issue reported on code.google.com by josemre...@gmail.com on 10 Feb 2013 at 11:22

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

Original comment by josemre...@gmail.com on 13 Feb 2013 at 10:33

GoogleCodeExporter commented 8 years ago

Original comment by jean.deruelle on 3 Jul 2013 at 8:57

GoogleCodeExporter commented 8 years ago

Original comment by jean.deruelle on 12 Jul 2013 at 3:52