Module: kamailio Branch: master Commit: 5f83d4f9c447f5a7e3de8336dc0e076b10e43833 URL: https://github.com/kamailio/kamailio/commit/5f83d4f9c447f5a7e3de8336dc0e076b...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-04-03T12:18:47+02:00
core: msg translator - duplicate reply via xavp params and handle errors
---
Modified: src/core/msg_translator.c
---
Diff: https://github.com/kamailio/kamailio/commit/5f83d4f9c447f5a7e3de8336dc0e076b... Patch: https://github.com/kamailio/kamailio/commit/5f83d4f9c447f5a7e3de8336dc0e076b...
---
diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c index b54eded3f89..acd5911867a 100644 --- a/src/core/msg_translator.c +++ b/src/core/msg_translator.c @@ -2362,6 +2362,7 @@ char *generate_res_buf_from_sip_res( char *buf; unsigned int len; str xparams; + str sdup; sr_lump_t *anchor;
buf = msg->buf; @@ -2393,11 +2394,18 @@ char *generate_res_buf_from_sip_res( anchor = anchor_lump(msg, msg->via2->params.s + msg->via2->params.len - msg->buf, 0, 0); - if(anchor != NULL) { - if(insert_new_lump_after(anchor, xparams.s, xparams.len, 0) - == 0) { - LM_ERR("unable to add via reply xavp params\n"); - } + if(anchor == NULL) { + LM_ERR("unable to get the anchor\n"); + goto error; + } + if(pkg_str_dup(&sdup, &xparams) < 0) { + PKG_MEM_ERROR; + goto error; + } + if(insert_new_lump_after(anchor, sdup.s, sdup.len, 0) == 0) { + LM_ERR("unable to add via reply xavp params\n"); + pkg_free(sdup.s); + goto error; } } }