Skip to content

Commit 6479e9b

Browse files
Fix: udw buffer overflow
1 parent 5161836 commit 6479e9b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ecosystem/gstreamer_plugin/gst_mtl_st40p_tx.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ static GstFlowReturn gst_mtl_st40p_tx_parse_8331_anc_words(
582582
* data_size points to the correct offset for the current ANC packet
583583
*/
584584
if (gst_mtl_st40p_tx_parse_8331_meta(frame_info, payload_header, i,
585-
frame_info->anc_frame->data_size)) {
585+
frame_info->udw_buffer_fill)) {
586586
GST_ERROR("Failed to parse 8331 meta");
587587
return GST_FLOW_ERROR;
588588
}
@@ -595,13 +595,17 @@ static GstFlowReturn gst_mtl_st40p_tx_parse_8331_anc_words(
595595
* Start processing actual user data words from the 3rd UDW onward.
596596
*/
597597
for (int j = 0; j < data_count; j++) {
598+
if (frame_info->udw_buffer_fill >= frame_info->udw_buffer_size) {
599+
GST_ERROR("UDW buffer overflow: fill=%u size=%zu", frame_info->udw_buffer_fill, frame_info->udw_buffer_size);
600+
return GST_FLOW_ERROR;
601+
}
602+
598603
udw = st40_get_udw((j + 3), payload_cursor);
599604
if (!st40_check_parity_bits(udw)) {
600605
GST_ERROR("Ancillary data parity bits check failed");
601606
return GST_FLOW_ERROR;
602607
}
603-
604-
frame_info->udw_buff_addr[frame_info->udw_buffer_fill++] = udw & 0xff;
608+
frame_info->udw_buff_addr[frame_info->udw_buffer_fill++] = (udw & 0xff);
605609
}
606610

607611
bytes_left_to_process -= udw_byte_size;
@@ -711,6 +715,10 @@ static GstFlowReturn gst_mtl_st40p_tx_parse_memory_block(Gst_Mtl_St40p_Tx* sink,
711715
: bytes_left_to_process;
712716

713717
memcpy(frame_info->udw_buff_addr, cur_addr_buf, bytes_left_to_process_cur);
718+
for (int i = 0; i < bytes_left_to_process_cur; i++) {
719+
printf("%d", frame_info->udw_buff_addr[i]);
720+
}
721+
printf("\n");
714722

715723
gst_mtl_st40p_tx_fill_meta(frame_info->anc_frame, frame_info->udw_buff_addr,
716724
bytes_left_to_process_cur, sink->did, sink->sdid);

0 commit comments

Comments
 (0)