Module: sip-router
Branch: master
Commit: b255c406ba09ff229361a3bc14cc1c9fd076b52e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b255c40…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Nov 9 11:03:46 2012 +0100
core: tcp - proper handling of '\n-' sequence for detecting end of MSRP frame
- in some cases it could go in wrong reading MSRP state
- reported by Gavin Llewellyn
---
tcp_read.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tcp_read.c b/tcp_read.c
index 1c80c19..b969e6c 100644
--- a/tcp_read.c
+++ b/tcp_read.c
@@ -934,14 +934,16 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
if(r->pos - r->start < 10) {
LM_ERR("weird situation when reading MSRP frame"
" - continue reading\n");
+ /* *p=='\n' */
+ r->state=H_MSRP_BODY_LF;
p++;
- r->state=H_MSRP_BODY;
break;
}
if(*(p-1)!='\r') {
/* not ending in '\r\n' - not end-line */
+ /* *p=='\n' */
+ r->state=H_MSRP_BODY_LF;
p++;
- r->state=H_MSRP_BODY;
break;
}
/* locate transaction id in first line
@@ -956,16 +958,18 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
p - 1 /*\r*/ - 1 /* '+'|'#'|'$' */ - mtransid.len,
mtransid.len)!=0) {
/* no match on session id - not end-line */
+ /* *p=='\n' */
+ r->state=H_MSRP_BODY_LF;
p++;
- r->state=H_MSRP_BODY;
break;
}
if(memcmp(p - 1 /*\r*/ - 1 /* '+'|'#'|'$' */ - mtransid.len
- 7 /* 7 x '-' */ - 1 /* '\n' */, "\n-------",
8)!=0) {
/* no match on "\n-------" - not end-line */
+ /* *p=='\n' */
+ r->state=H_MSRP_BODY_LF;
p++;
- r->state=H_MSRP_BODY;
break;
}
r->state=H_MSRP_FINISH;