MT#55283 rtpe: use extract_body with read_sdp_pv

If the module uses an SDP taken from a pvar, and the current message
uses a multipart content, don't replace the entire message body with the
rewritten SDP, but only the part of the body that is SDP.

Change-Id: I9e43a7c2179c4887f16213c1a2fa2d2bf76b7764
mr13.0
Richard Fuchs 2 years ago
parent e36b0885b3
commit d1bfda3fc8

@ -39,6 +39,7 @@ upstream/cfgutils-expose-optional-second-string-key-for-lock.patch
upstream/cfgutils-initialize-the-optional-key.patch
upstream/permissions_add_register_allow_with_port_check.patch
upstream/dialplan-don-t-call-free-on-empty-pcre-pointer.patch
upstream/multipart-sdp.patch
### relevant for upstream
sipwise/dialplan-don-t-stop-loading-rules-on-error.patch
sipwise/kamctl-TMPDIR-config.patch

@ -0,0 +1,57 @@
--- a/src/modules/rtpengine/rtpengine.c
+++ b/src/modules/rtpengine/rtpengine.c
@@ -4693,28 +4693,13 @@
pkg_free(newbody.s);
} else {
- if(cl_field.len) {
- anchor = del_lump(msg, cl_field.s - msg->buf, cl_field.len, 0);
- cl_repl.s = pkg_malloc(10);
- if(!cl_repl.s) {
- LM_ERR("pkg_malloc for Content-Length failed\n");
- goto error_free;
- }
- cl_repl.len = snprintf(cl_repl.s, 10, "%i", (int)newbody.len);
- if(!insert_new_lump_after(anchor, cl_repl.s, cl_repl.len, 0)) {
- LM_ERR("insert_new_lump_after failed\n");
- goto error_free;
- }
- cl_repl.s = NULL;
- }
-
if(read_sdp_pvar_str.len > 0) {
/* get the body from the message as body ptr may have changed
* when using read_sdp_pv */
- cur_body.len = 0;
- cur_body.s = get_body(msg);
- cur_body.len = msg->buf + msg->len - cur_body.s;
-
+ if(extract_body(msg, &cur_body, &cl_field) == -1) {
+ LM_ERR("failed to extract body from message");
+ goto error_free;
+ }
anchor = del_lump(msg, cur_body.s - msg->buf, cur_body.len, 0);
} else {
anchor = del_lump(msg, body.s - msg->buf, body.len, 0);
@@ -4727,6 +4712,21 @@
LM_ERR("insert_new_lump_after failed\n");
goto error_free;
}
+
+ if(cl_field.len) {
+ anchor = del_lump(msg, cl_field.s - msg->buf, cl_field.len, 0);
+ cl_repl.s = pkg_malloc(10);
+ if(!cl_repl.s) {
+ LM_ERR("pkg_malloc for Content-Length failed\n");
+ goto error_free;
+ }
+ cl_repl.len = snprintf(cl_repl.s, 10, "%i", (int)newbody.len);
+ if(!insert_new_lump_after(anchor, cl_repl.s, cl_repl.len, 0)) {
+ LM_ERR("insert_new_lump_after failed\n");
+ goto error_free;
+ }
+ cl_repl.s = NULL;
+ }
}
}
Loading…
Cancel
Save