Skip to content

Commit

Permalink
Fix segfault in MCM FFmpeg plugin occurred in memcpy
Browse files Browse the repository at this point in the history
In mcm_read_packet() the length of the buffer received from
media_proxy can be smaller than the configured frame size.
Passing the size argument to memcpy() being larger than the
source buffer size can lead to a segmentation fault.

This commit fixes this issue by passing the size argument to
memcpy() as the lowest value between the configured frame
size and the actual Rx buffer length.

Signed-off-by: Konstantin Ilichev <[email protected]>
  • Loading branch information
ko80 authored and soopel committed Jun 26, 2024
1 parent a38955b commit 4259a18
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ffmpeg-plugin/mcm_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static int mcm_read_packet(AVFormatContext* avctx, AVPacket* pkt)
if ((ret = av_new_packet(pkt, s->frame_size)) < 0)
return ret;

memcpy(pkt->data, buf->data, s->frame_size);
memcpy(pkt->data, buf->data, FFMIN(s->frame_size, buf->len));

pkt->pts = pkt->dts = AV_NOPTS_VALUE;

Expand Down

0 comments on commit 4259a18

Please sign in to comment.