From ce66c7b8fa8740965fa42aa6b9cf6325ee978a93 Mon Sep 17 00:00:00 2001 From: Tom Briden Date: Wed, 24 Apr 2024 15:46:07 +0100 Subject: [PATCH] MT#55283 codec_add_raw_packet_dup: allocate enough space to support encrpytion using str_init_dup_str doesn't leave enough room for appending encryption related pieces to the end of the packet when used for, eg, dtmf injection closes #1819 Change-Id: Iefae0e04b38f4a3eaaac32ed1ba70c7e3ee8e979 --- daemon/codec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/daemon/codec.c b/daemon/codec.c index 5dd94c354..864408a4e 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1717,7 +1717,13 @@ void codec_add_raw_packet(struct media_packet *mp, unsigned int clockrate) { #ifdef WITH_TRANSCODING static void codec_add_raw_packet_dup(struct media_packet *mp, unsigned int clockrate) { struct codec_packet *p = g_slice_alloc0(sizeof(*p)); - str_init_dup_str(&p->s, &mp->raw); + // don't just duplicate the string. need to ensure enough room + // if encryption is enabled on this stream + char *buf = g_malloc(mp->raw.len + 1 + RTP_BUFFER_TAIL_ROOM); + if (mp->raw.s && mp->raw.len) + memcpy(buf, mp->raw.s, mp->raw.len); + p->s.len = mp->raw.len; + p->s.s = buf; p->free_func = free; p->rtp = (struct rtp_header *) p->s.s; codec_add_raw_packet_common(mp, clockrate, p);