ALP: fix issue #18795 (memory management issues)

This patch replaces memcpy to tvb_memcpy, also fixes while() loop over numts
This commit is contained in:
Sergey V. Lobanov 2023-01-10 21:37:20 +01:00 committed by Gerald Combs
parent 5e3dba3da0
commit 8a4f22be61
1 changed files with 4 additions and 4 deletions

View File

@ -232,7 +232,7 @@ dissect_alp_mpegts(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *t
guchar *ts_frame = (guchar*)wmem_alloc(pinfo->pool, 188);
ts_frame[0] = 0x47;
memcpy(ts_frame + 1, tvb_get_ptr(tvb, offset, -1), 187);
tvb_memcpy(tvb, ts_frame + 1, offset, 187);
offset += 187;
guchar header[4];
@ -241,17 +241,17 @@ dissect_alp_mpegts(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *t
tvbuff_t *ts_frame_tvb = tvb_new_child_real_data(tvb, ts_frame, 188, 188);
call_dissector(ts_handle, ts_frame_tvb, pinfo, tree);
while (numts--) {
while (--numts) {
ts_frame = (guchar*)wmem_alloc(pinfo->pool, 188);
if (hdm) {
header[3] = (header[3] & 0xF0) | ((header[3] + 1) & 0x0F);
memcpy(ts_frame, header, 4);
memcpy(ts_frame + 4, tvb_get_ptr(tvb, offset, -1), 184);
tvb_memcpy(tvb, ts_frame + 4, offset, 184);
offset += 184;
} else {
ts_frame[0] = 0x47;
memcpy(ts_frame + 1, tvb_get_ptr(tvb, offset, -1), 187);
tvb_memcpy(tvb, ts_frame + 1, offset, 187);
offset += 187;
}