Module: sip-router Branch: master Commit: caef5ace2026fcb2a9dffb471e2cec6d843082f8 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=caef5ace...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Jun 22 17:25:18 2009 +0200
nathelper(k): skip trailing whitespaces and crlf
- was affecting multipart bodies, causing nortpproxy string to be placed in the wrong position - reported by Pascal Maugeri
---
modules_k/nathelper/nhelpr_funcs.c | 33 ++++++++++++++++++--------------- 1 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/modules_k/nathelper/nhelpr_funcs.c b/modules_k/nathelper/nhelpr_funcs.c index 4d5bd99..95f2133 100644 --- a/modules_k/nathelper/nhelpr_funcs.c +++ b/modules_k/nathelper/nhelpr_funcs.c @@ -206,21 +206,9 @@ int extract_body(struct sip_msg *msg, str *body ) goto error; }
- for (skip = 0; skip < body->len; skip++) { - c = body->s[body->len - skip - 1]; - if (c != '\r' && c != '\n') - break; - } - if (skip == body->len) { - LM_ERR("empty body"); - goto error; - } - body->len -= skip; - - /*LM_DBG("DEBUG:extract_body:=|%.*s|\n",body->len,body->s);*/ - if(ret!=2) - return 1; + goto done; + /* multipart body */ if(get_mixed_part_delimiter(&msg->content_type->body,&mpdel) < 0) { goto error; @@ -266,12 +254,27 @@ int extract_body(struct sip_msg *msg, str *body ) { body->s = rest; body->len = p2-rest; - return 1; + goto done; } }
error: return -1; + +done: + for (skip = 0; skip < body->len; skip++) { + c = body->s[body->len - skip - 1]; + if (c != '\r' && c != '\n') + break; + } + if (skip == body->len) { + LM_ERR("empty body"); + goto error; + } + body->len -= skip; + + /*LM_DBG("DEBUG:extract_body:=|%.*s|\n",body->len,body->s);*/ + return 1; }
/*