From b97470d1b7d08c4787ef2789cf6f943f0809436b Mon Sep 17 00:00:00 2001
From: John Thacker <johnthacker@gmail.com>
Date: Wed, 11 Mar 2026 10:11:59 +0000
Subject: [PATCH] fcswils: Add recursion checks

The Fibre Channel dissector supports reassembly, so we won't necessarily
run out of packet before running out of stack.

Fix #21070

Thanks to bcoles for reporting this.

AI-Assisted: no


(cherry picked from commit 202b29b237151f1ff75ee7664bbeffe9fe46eb97)

Co-authored-by: John Thacker <johnthacker@gmail.com>
---
 epan/dissectors/packet-fcswils.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/epan/dissectors/packet-fcswils.c b/epan/dissectors/packet-fcswils.c
index 4e7dee73cf5..9850d113002 100644
--- a/epan/dissectors/packet-fcswils.c
+++ b/epan/dissectors/packet-fcswils.c
@@ -1231,8 +1231,11 @@ dissect_swils_zone_obj(tvbuff_t *tvb, packet_info* pinfo, proto_tree *zobj_tree,
     offset += 8 + ZONENAME_LEN(tvb, offset+4);
     for (i = 0; i < numrec; i++) {
         if (objtype == FC_SWILS_ZONEOBJ_ZONESET) {
-            // We recurse here, but we'll run out of packet before we run out of stack.
+            increment_dissection_depth(pinfo);
+            /* XXX - Is it legal to have more than one level of nesting here?
+             * get_zoneobj_len assumes one at most. Should there be a subtree? */
             dissect_swils_zone_obj(tvb, pinfo, zobj_tree, offset);
+            decrement_dissection_depth(pinfo);
             offset += get_zoneobj_len(tvb, offset);
         }
         else {
-- 
GitLab

