-
Notifications
You must be signed in to change notification settings - Fork 8
/
10882.diff
150 lines (127 loc) · 5.59 KB
/
10882.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
commit 1a9f074c0c03a1cfae6f63d183ae1791ac11b532
Author: Peter Wu <[email protected]>
Date: Tue Oct 9 21:25:35 2018 +0200
OSITP: do not call subdissector if there is no data
None of the current heuristics dissectors for "cotp" accept the packet,
so just skip calling subdissectors if the packet is empty.
Change-Id: Ie26f05d472b4d184d5229ceab8b143a88cc921fc
Reviewed-on: https://code.wireshark.org/review/30103
Petri-Dish: Peter Wu <[email protected]>
Reviewed-by: Émilio Gonzalez <[email protected]>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <[email protected]>
diff --git a/epan/dissectors/packet-ositp.c b/epan/dissectors/packet-ositp.c
index 47c691d530..1c3c7381e0 100644
--- a/epan/dissectors/packet-ositp.c
+++ b/epan/dissectors/packet-ositp.c
@@ -1480,116 +1480,118 @@ static int ositp_decode_RJ(tvbuff_t *tvb, int offset, guint8 li, guint8 tpdu,
static int ositp_decode_CR_CC(tvbuff_t *tvb, int offset, guint8 li, guint8 tpdu,
packet_info *pinfo, proto_tree *tree,
gboolean uses_inactive_subset,
gboolean *subdissector_found)
{
/* note: in the ATN the user is up to chose between 3 different checksums:
* standard OSI, 2 or 4 octet extended checksum.
* Nothing has to be done here, for all ATN specifics are handled in VP. */
/* CC & CR decoding in the same function */
proto_tree *cotp_tree = NULL;
proto_item *ti;
proto_item *item = NULL;
guint16 dst_ref, src_ref;
guint8 class_option;
tvbuff_t *next_tvb;
guint tpdu_len;
heur_dtbl_entry_t *hdtbl_entry;
static const int * class_options[] = {
&hf_cotp_class,
&hf_cotp_opts_extended_formats,
&hf_cotp_opts_no_explicit_flow_control,
NULL,
};
src_ref = tvb_get_ntohs(tvb, offset + P_SRC_REF);
class_option = tvb_get_guint8(tvb, offset + P_CLASS_OPTION);
if (((class_option & 0xF0) >> 4) > 4) /* class 0..4 allowed */
return -1;
/* CR and CC TPDUs can have user data, so they run to the end of the
* containing PDU */
tpdu_len = tvb_reported_length_remaining(tvb, offset);
dst_ref = tvb_get_ntohs(tvb, offset + P_DST_REF);
pinfo->clnp_srcref = src_ref;
pinfo->clnp_dstref = dst_ref;
col_append_fstr(pinfo->cinfo, COL_INFO,
"%s TPDU src-ref: 0x%04x dst-ref: 0x%04x",
(tpdu == CR_TPDU) ? "CR" : "CC", src_ref, dst_ref);
ti = proto_tree_add_item(tree, proto_cotp, tvb, offset, li + 1, ENC_NA);
cotp_tree = proto_item_add_subtree(ti, ett_cotp);
proto_tree_add_uint(cotp_tree, hf_cotp_li, tvb, offset, 1,li);
offset += 1;
item = proto_tree_add_uint(cotp_tree, hf_cotp_type, tvb, offset, 1, tpdu);
offset += 1;
li -= 1;
proto_tree_add_uint(cotp_tree, hf_cotp_destref, tvb, offset, 2, dst_ref);
offset += 2;
li -= 2;
proto_tree_add_uint(cotp_tree, hf_cotp_srcref, tvb, offset, 2, src_ref);
offset += 2;
li -= 2;
/* expert info, but only if not encapsulated in TCP/SMB */
/* XXX - the best way to detect seems to be if we have a port set */
if (pinfo->destport == 0) {
expert_add_info_format(pinfo, item, &ei_cotp_connection, "Connection %s: 0x%x -> 0x%x", tpdu == CR_TPDU ? "Request(CR)" : "Confirm(CC)", src_ref, dst_ref);
}
proto_tree_add_bitmask_list(cotp_tree, tvb, offset, 1, class_options, ENC_NA);
offset += 1;
li -= 1;
if (li > 0) {
/* There's more data left, so we have the variable part.
Microsoft's RDP hijacks the variable part of CR and CC PDUs
for their own user data (RDP runs atop Class 0, which doesn't
support user data).
Try what heuristic dissectors we have. */
next_tvb = tvb_new_subset_length(tvb, offset, li);
if (dissector_try_heuristic((tpdu == CR_TPDU) ?
cotp_cr_heur_subdissector_list :
cotp_cc_heur_subdissector_list,
next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
/* A subdissector claimed this, so it really belongs to them. */
*subdissector_found = TRUE;
} else {
/* No heuristic dissector claimed it, so dissect it as a regular
variable part. */
ositp_decode_var_part(tvb, offset, li, class_option, tpdu_len, pinfo,
cotp_tree);
}
offset += li;
}
/*
* XXX - tell the subdissector that this is user data in a CR or
* CC packet rather than a DT packet?
*/
- next_tvb = tvb_new_subset_remaining(tvb, offset);
- if (!uses_inactive_subset){
- if (dissector_try_heuristic(cotp_heur_subdissector_list, next_tvb, pinfo,
- tree, &hdtbl_entry, NULL)) {
- *subdissector_found = TRUE;
- } else {
- call_data_dissector(next_tvb, pinfo, tree);
+ if (tvb_captured_length_remaining(tvb, offset)) {
+ next_tvb = tvb_new_subset_remaining(tvb, offset);
+ if (!uses_inactive_subset){
+ if (dissector_try_heuristic(cotp_heur_subdissector_list, next_tvb, pinfo,
+ tree, &hdtbl_entry, NULL)) {
+ *subdissector_found = TRUE;
+ } else {
+ call_data_dissector(next_tvb, pinfo, tree);
+ }
}
+ else
+ call_data_dissector( next_tvb, pinfo, tree);
+ offset += tvb_captured_length_remaining(tvb, offset);
+ /* we dissected all of the containing PDU */
}
- else
- call_data_dissector( next_tvb, pinfo, tree);
- offset += tvb_captured_length_remaining(tvb, offset);
- /* we dissected all of the containing PDU */
return offset;
} /* ositp_decode_CR_CC */