diff options
author | Gerald Combs <gerald@wireshark.org> | 2024-02-20 09:41:29 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2024-02-20 11:16:22 -0800 |
commit | 16d85df6f447b082afce8cf183d187d6144f2870 (patch) | |
tree | 60a8631c4222391150dc43d4ebd924ce7f09ca9d | |
parent | 45f9dae43cc9f6253bc8e8f2d12afa47a8925e62 (diff) |
ISIS LSP: Add a recursion check
Fix
```
wireshark/epan/dissectors/packet-isis-lsp.c:3431:1: warning: function 'dissect_sub_clv_tlv_22_22_23_141_222_223' is within a recursive call chain [misc-no-recursion]
3431 | dissect_sub_clv_tlv_22_22_23_141_222_223(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree,
| ^
wireshark/epan/dissectors/packet-isis-lsp.c:3431:1: note: example recursive call chain, starting from function 'dissect_sub_clv_tlv_22_22_23_141_222_223'
wireshark/epan/dissectors/packet-isis-lsp.c:3541:21: note: Frame #1: function 'dissect_sub_clv_tlv_22_22_23_141_222_223' calls function 'dissect_sub_clv_tlv_22_22_23_141_222_223' here:
3541 | dissect_sub_clv_tlv_22_22_23_141_222_223(tvb, pinfo, subtree, local_offset, local_len);
| ^
wireshark/epan/dissectors/packet-isis-lsp.c:3541:21: note: ... which was the starting point of the recursive call chain; there may be other cycles
```
Add Clang-Tidy suppressions as well.
-rw-r--r-- | epan/dissectors/packet-isis-lsp.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/epan/dissectors/packet-isis-lsp.c b/epan/dissectors/packet-isis-lsp.c index decb8daa0d..6021ddc492 100644 --- a/epan/dissectors/packet-isis-lsp.c +++ b/epan/dissectors/packet-isis-lsp.c @@ -21,8 +21,10 @@ #include "config.h" -#include <epan/packet.h> #include <epan/expert.h> +#include <epan/packet.h> +#include <epan/proto_data.h> + #include "packet-osi.h" #include "packet-isis.h" #include "packet-isis-clv.h" @@ -3427,7 +3429,10 @@ dissect_srv6_sid_struct_subsubclv(tvbuff_t *tvb, packet_info* pinfo, * void */ +#define MAX_RECURSION_DEPTH 10 // Arbitrarily chosen. + static void +// NOLINTNEXTLINE(misc-no-recursion) dissect_sub_clv_tlv_22_22_23_141_222_223(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset, int subclvs_len) { @@ -3445,6 +3450,10 @@ dissect_sub_clv_tlv_22_22_23_141_222_223(tvbuff_t *tvb, packet_info* pinfo, prot proto_tree *subsubtree = NULL; proto_item *ti_subsubtree = NULL; + unsigned recursion_depth = p_get_proto_depth(pinfo, proto_isis_lsp); + DISSECTOR_ASSERT(recursion_depth <= MAX_RECURSION_DEPTH); + p_set_proto_depth(pinfo, proto_isis_lsp, recursion_depth + 1); + while (i < subclvs_len) { /* offset for each sub-TLV */ sub_tlv_offset = offset + i; @@ -3704,8 +3713,9 @@ dissect_sub_clv_tlv_22_22_23_141_222_223(tvbuff_t *tvb, packet_info* pinfo, prot proto_tree_add_item(subtree, hf_isis_lsp_ext_is_reachability_value, tvb, sub_tlv_offset, clv_len, ENC_NA); break; } - i += clv_len + 2; - } + i += clv_len + 2; + } + p_set_proto_depth(pinfo, proto_isis_lsp, recursion_depth); } |