Module: kamailio Branch: master Commit: 98249e2cc97e818cf7ad492132ecfea2ce13a78b URL: https://github.com/kamailio/kamailio/commit/98249e2cc97e818cf7ad492132ecfea2ce13a78b
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2019-08-12T11:14:38+02:00 core: forward - clone outbound buffer for SREV_NET_DATA_OUT event - this event can execute a series of callbacks, leading to leak if only the core function does pkg free - GH #2027 --- Modified: src/core/forward.h --- Diff: https://github.com/kamailio/kamailio/commit/98249e2cc97e818cf7ad492132ecfea2ce13a78b.diff Patch: https://github.com/kamailio/kamailio/commit/98249e2cc97e818cf7ad492132ecfea2ce13a78b.patch --- diff --git a/src/core/forward.h b/src/core/forward.h index d039900aac..a629748686 100644 --- a/src/core/forward.h +++ b/src/core/forward.h @@ -136,9 +136,18 @@ static inline int msg_send_buffer(struct dest_info* dst, char* buf, int len, outb.s = buf; outb.len = len; if(!(flags&1)) { - evp.data = (void*)&outb; - evp.dst = dst; - sr_event_exec(SREV_NET_DATA_OUT, &evp); + if(sr_event_enabled(SREV_NET_DATA_OUT)) { + outb.s = (char*)pkg_malloc(len + 1); + if(outb.s==NULL) { + LM_ERR("failed to clone outgoing buffer\n"); + return -1; + } + memcpy(outb.s, buf, len); + outb.s[len] = '\0'; + evp.data = (void*)&outb; + evp.dst = dst; + sr_event_exec(SREV_NET_DATA_OUT, &evp); + } } if(outb.s==NULL) { _______________________________________________ Kamailio (SER) - Development Mailing List [email protected] https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
