Skip to content

Commit

Permalink
MT#55283 codec_add_raw_packet_dup: allocate enough space to support e…
Browse files Browse the repository at this point in the history
…ncrpytion

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
(cherry picked from commit ce66c7b)
(cherry picked from commit 4fd891f)
  • Loading branch information
tombriden authored and rfuchs committed Nov 1, 2024
1 parent 791654b commit 4bf321a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion daemon/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,13 @@ void codec_add_raw_packet(struct media_packet *mp, unsigned int clockrate) {
}
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);
Expand Down

0 comments on commit 4bf321a

Please sign in to comment.