From cea357ad0501b8d4ab281716564833999308142f Mon Sep 17 00:00:00 2001
From: John Thacker <johnthacker@gmail.com>
Date: Fri, 3 Apr 2026 07:03:40 -0400
Subject: [PATCH] DCP ETSI: Check that all fragments are the same size with R-S

ETSI TS 102.821 7.3.2 Fragmentation:
"Note that when Reed Solomon has been used, all fragments will be
of length s."

Fix #21144

AI-Assisted: no

(backported from 2a44f117ad799228bfe51467843b3a01fae3787c)
---
 epan/dissectors/packet-dcp-etsi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: wireshark-3.6.24/epan/dissectors/packet-dcp-etsi.c
===================================================================
--- wireshark-3.6.24.orig/epan/dissectors/packet-dcp-etsi.c
+++ wireshark-3.6.24/epan/dissectors/packet-dcp-etsi.c
@@ -333,8 +333,15 @@ dissect_pft_fec_detailed(tvbuff_t * tvb,
   if(new_tvb && tvb_captured_length(new_tvb) > 0) {
     gboolean decoded;
     tvbuff_t *dtvb = NULL;
-    const guint8 *input = tvb_get_ptr(new_tvb, 0, -1);
     guint32 reassembled_size = tvb_captured_length(new_tvb);
+    /* "Note that when Reed Solomon has been used, all fragments will
+     * be of length s" [i.e., plen]" */
+    if (reassembled_size != fcount * plen) {
+      proto_tree_add_expert_format(tree, pinfo, &ei_edcp_reassembly, new_tvb, 0, -1, "[All fragments must be the same size when Reed Solomon is used]");
+      return NULL;
+    }
+    const guint8 *input = tvb_get_ptr(new_tvb, 0, reassembled_size);
+
     guint8 *deinterleaved = (guint8*) wmem_alloc(pinfo->pool, reassembled_size);
     rs_deinterleave(input, deinterleaved, plen, fcount);
 
