- check boundary cannot find boundary value in content-type when the request
is turned into multipart body
- use different return code for this case
- a few realignmets for curly braces to be corherent across the
respective functions
... | ... |
@@ -1710,16 +1710,14 @@ int get_boundary(struct sip_msg* msg, str* boundary) |
1710 | 1710 |
|
1711 | 1711 |
params.s = memchr(msg->content_type->body.s, ';', |
1712 | 1712 |
msg->content_type->body.len); |
1713 |
- if (params.s == NULL) |
|
1714 |
- { |
|
1713 |
+ if (params.s == NULL) { |
|
1715 | 1714 |
LM_INFO("Content-Type hdr has no boundary params <%.*s>\n", |
1716 | 1715 |
msg->content_type->body.len, msg->content_type->body.s); |
1717 |
- return -1; |
|
1716 |
+ return -2; |
|
1718 | 1717 |
} |
1719 | 1718 |
params.len = msg->content_type->body.len - |
1720 | 1719 |
(params.s - msg->content_type->body.s); |
1721 |
- if (parse_params(¶ms, CLASS_ANY, &hooks, &list) < 0) |
|
1722 |
- { |
|
1720 |
+ if (parse_params(¶ms, CLASS_ANY, &hooks, &list) < 0) { |
|
1723 | 1721 |
LM_ERR("while parsing Content-Type params\n"); |
1724 | 1722 |
return -1; |
1725 | 1723 |
} |
... | ... |
@@ -1727,11 +1725,9 @@ int get_boundary(struct sip_msg* msg, str* boundary) |
1727 | 1725 |
boundary->len = 0; |
1728 | 1726 |
for (p = list; p; p = p->next) { |
1729 | 1727 |
if ((p->name.len == 8) |
1730 |
- && (strncasecmp(p->name.s, "boundary", 8) == 0)) |
|
1731 |
- { |
|
1728 |
+ && (strncasecmp(p->name.s, "boundary", 8) == 0)) { |
|
1732 | 1729 |
boundary->s = pkg_malloc(p->body.len + 2); |
1733 |
- if (boundary->s == NULL) |
|
1734 |
- { |
|
1730 |
+ if (boundary->s == NULL) { |
|
1735 | 1731 |
free_params(list); |
1736 | 1732 |
PKG_MEM_ERROR; |
1737 | 1733 |
return -1; |
... | ... |
@@ -1764,9 +1760,17 @@ int check_boundaries(struct sip_msg *msg, struct dest_info *send_info) |
1764 | 1760 |
int t, ret, lb_size; |
1765 | 1761 |
char *pb; |
1766 | 1762 |
|
1767 |
- if(!(msg->msg_flags&FL_BODY_MULTIPART)) return 0; |
|
1768 |
- else |
|
1769 |
- { |
|
1763 |
+ if(!(msg->msg_flags&FL_BODY_MULTIPART)) { |
|
1764 |
+ LM_DBG("no multi-part body\n"); |
|
1765 |
+ return 0; |
|
1766 |
+ } else { |
|
1767 |
+ if((t = get_boundary(msg, &ob)) != 0) { |
|
1768 |
+ if(t==-2) { |
|
1769 |
+ LM_INFO("no boundary - maybe just turning into multipart body\n"); |
|
1770 |
+ return -2; |
|
1771 |
+ } |
|
1772 |
+ return -1; |
|
1773 |
+ } |
|
1770 | 1774 |
buf.s = build_body(msg, (unsigned int *)&buf.len, &ret, send_info); |
1771 | 1775 |
if(ret) { |
1772 | 1776 |
LM_ERR("Can't get body\n"); |
... | ... |
@@ -1774,10 +1778,6 @@ int check_boundaries(struct sip_msg *msg, struct dest_info *send_info) |
1774 | 1778 |
} |
1775 | 1779 |
tmp.s = buf.s; |
1776 | 1780 |
t = tmp.len = buf.len; |
1777 |
- if(get_boundary(msg, &ob)!=0) { |
|
1778 |
- if(tmp.s) pkg_free(tmp.s); |
|
1779 |
- return -1; |
|
1780 |
- } |
|
1781 | 1781 |
if(str_append(&ob, &bsuffix, &b)!=0) { |
1782 | 1782 |
LM_ERR("Can't append suffix to boundary\n"); |
1783 | 1783 |
goto error; |
... | ... |
@@ -1961,6 +1961,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg, |
1961 | 1961 |
unsigned int flags; |
1962 | 1962 |
unsigned int udp_mtu; |
1963 | 1963 |
struct dest_info di; |
1964 |
+ int ret; |
|
1964 | 1965 |
|
1965 | 1966 |
via_insert_param=0; |
1966 | 1967 |
uri_len=0; |
... | ... |
@@ -1978,9 +1979,10 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg, |
1978 | 1979 |
path_buf.len=0; |
1979 | 1980 |
|
1980 | 1981 |
flags=msg->msg_flags|global_req_flags; |
1981 |
- if(check_boundaries(msg, send_info)<0){ |
|
1982 |
- LM_WARN("check_boundaries error\n"); |
|
1982 |
+ if((ret = check_boundaries(msg, send_info)) < 0){ |
|
1983 |
+ LM_INFO("check boundaries negative (%d)\n", ret); |
|
1983 | 1984 |
} |
1985 |
+ |
|
1984 | 1986 |
/* Calculate message body difference and adjust Content-Length */ |
1985 | 1987 |
body_delta = lumps_len(msg, msg->body_lumps, send_info); |
1986 | 1988 |
if (adjust_clen(msg, body_delta, send_info->proto) < 0) { |