From 0b874ad0f50f71a5b780cb915ea62f8625112402 Mon Sep 17 00:00:00 2001
From: Jaap Keuter <jaap.keuter@xs4all.nl>
Date: Thu, 27 Jul 2023 20:21:19 +0200
Subject: [PATCH] CP2179: Handle timetag info response without records

Fixes #19229

(cherry picked from commit 44dc70cc5aadca91cb8ba3710c59c3651b7b0d4d)
---
 epan/dissectors/packet-cp2179.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/epan/dissectors/packet-cp2179.c b/epan/dissectors/packet-cp2179.c
index 30f53f84946..70fe0332843 100644
--- a/epan/dissectors/packet-cp2179.c
+++ b/epan/dissectors/packet-cp2179.c
@@ -721,11 +721,14 @@ dissect_response_frame(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int
                     proto_tree_add_item(cp2179_proto_tree, hf_cp2179_timetag_numsets, tvb, offset, 1, ENC_LITTLE_ENDIAN);
 
                     num_records = tvb_get_guint8(tvb, offset) & 0x7F;
+                    offset += 1;
+
+                    if (num_records == 0 || numberofcharacters <= 1)
+                        break;
+
                     recordsize = (numberofcharacters-1) / num_records;
                     num_values = (recordsize-6) / 2;      /* Determine how many 16-bit analog values are present in each event record */
 
-                    offset += 1;
-
                     for (x = 0; x < num_records; x++)
                     {
                         cp2179_event_tree = proto_tree_add_subtree_format(cp2179_proto_tree, tvb, offset, recordsize, ett_cp2179_event, NULL, "Event Record # %d", x+1);
-- 
GitLab

