-
Notifications
You must be signed in to change notification settings - Fork 8
/
10842.diff
390 lines (354 loc) · 12.9 KB
/
10842.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
commit d9231144b652362eaf62f8595df7d4886dbaf44d
Author: Peter Wu <[email protected]>
Date: Tue Oct 9 17:23:44 2018 +0200
T125: avoid returning from TRY/CATCH in dissect_t125_heur
Doing so corrupts the exceptions stack and causes crashes elsewhere.
Move the heuristics check after get_ber_identifier as dissect_t125
calls that check too.
Bug: 15189
Change-Id: I816fcd693141c5e9e2979348f58bf5a8112290da
Fixes: v2.9.0rc0-2122-gf710f21833 ("T125: Add a heuristic test case.")
Reviewed-on: https://code.wireshark.org/review/30096
Petri-Dish: Peter Wu <[email protected]>
Reviewed-by: Émilio Gonzalez <[email protected]>
Petri-Dish: Gerald Combs <[email protected]>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <[email protected]>
diff --git a/epan/dissectors/asn1/t125/packet-t125-template.c b/epan/dissectors/asn1/t125/packet-t125-template.c
index 7212c5b3b7..4edde79f48 100644
--- a/epan/dissectors/asn1/t125/packet-t125-template.c
+++ b/epan/dissectors/asn1/t125/packet-t125-template.c
@@ -85,61 +85,56 @@ static gboolean
dissect_t125_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
gint8 ber_class;
gboolean pc;
gint32 tag;
volatile gboolean failed;
- gboolean is_t125;
/*
* We must catch all the "ran past the end of the packet" exceptions
* here and, if we catch one, just return FALSE. It's too painful
* to have a version of dissect_per_sequence() that checks all
* references to the tvbuff before making them and returning "no"
* if they would fail.
*/
failed = FALSE;
TRY {
- /*
- * Check that the first byte of the packet is a valid t125/MCS header.
- * This might not be enough, but since t125 only catch COTP packets,
- * it should not be a problem.
- */
- guint8 first_byte = tvb_get_guint8(tvb, 0) >> 2;
- switch (first_byte) {
- case HF_T125_ERECT_DOMAIN_REQUEST:
- case HF_T125_ATTACH_USER_REQUEST:
- case HF_T125_ATTACH_USER_CONFIRM:
- case HF_T125_CHANNEL_JOIN_REQUEST:
- case HF_T125_CHANNEL_JOIN_CONFIRM:
- case HF_T125_DISCONNECT_PROVIDER_ULTIMATUM:
- case HF_T125_SEND_DATA_REQUEST:
- case HF_T125_SEND_DATA_INDICATION:
- is_t125 = TRUE;
- break;
- default:
- is_t125 = FALSE;
- break;
- }
- if(is_t125) {
- dissect_t125(tvb, pinfo, parent_tree, NULL);
- return TRUE;
- }
-
/* could be BER */
get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);
} CATCH_BOUNDS_ERRORS {
failed = TRUE;
} ENDTRY;
- /* is this strong enough ? */
- if (!failed && ((ber_class==BER_CLASS_APP) && ((tag>=101) && (tag<=104)))) {
+ if (failed) {
+ return FALSE;
+ }
+
+ if (((ber_class==BER_CLASS_APP) && ((tag>=101) && (tag<=104)))) {
dissect_t125(tvb, pinfo, parent_tree, NULL);
return TRUE;
}
+ /*
+ * Check that the first byte of the packet is a valid t125/MCS header.
+ * This might not be enough, but since t125 only catch COTP packets,
+ * it should not be a problem.
+ */
+ guint8 first_byte = tvb_get_guint8(tvb, 0) >> 2;
+ switch (first_byte) {
+ case HF_T125_ERECT_DOMAIN_REQUEST:
+ case HF_T125_ATTACH_USER_REQUEST:
+ case HF_T125_ATTACH_USER_CONFIRM:
+ case HF_T125_CHANNEL_JOIN_REQUEST:
+ case HF_T125_CHANNEL_JOIN_CONFIRM:
+ case HF_T125_DISCONNECT_PROVIDER_ULTIMATUM:
+ case HF_T125_SEND_DATA_REQUEST:
+ case HF_T125_SEND_DATA_INDICATION:
+ dissect_t125(tvb, pinfo, parent_tree, NULL);
+ return TRUE;
+ }
+
return FALSE;
}
/*--- proto_register_t125 -------------------------------------------*/
diff --git a/epan/dissectors/packet-t125.c b/epan/dissectors/packet-t125.c
index d3fa7b9fc2..4abe431d12 100644
--- a/epan/dissectors/packet-t125.c
+++ b/epan/dissectors/packet-t125.c
@@ -1,45 +1,44 @@
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-t125.c */
/* asn2wrs.py -b -p t125 -c ./t125.cnf -s ./packet-t125-template -D . -O ../.. MCS-PROTOCOL.asn */
/* Input file: packet-t125-template.c */
#line 1 "./asn1/t125/packet-t125-template.c"
/* packet-t125.c
* Routines for t125 packet dissection
* Copyright 2007, Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/asn1.h>
-#include <epan/conversation.h>
#include "packet-ber.h"
#include "packet-per.h"
#include "packet-t124.h"
#define PNAME "MULTIPOINT-COMMUNICATION-SERVICE T.125"
#define PSNAME "T.125"
#define PFNAME "t125"
#define HF_T125_ERECT_DOMAIN_REQUEST 1
#define HF_T125_DISCONNECT_PROVIDER_ULTIMATUM 8
#define HF_T125_ATTACH_USER_REQUEST 10
#define HF_T125_ATTACH_USER_CONFIRM 11
#define HF_T125_CHANNEL_JOIN_REQUEST 14
#define HF_T125_CHANNEL_JOIN_CONFIRM 15
#define HF_T125_SEND_DATA_REQUEST 25
#define HF_T125_SEND_DATA_INDICATION 26
@@ -417,203 +416,198 @@ static gboolean
dissect_t125_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
gint8 ber_class;
gboolean pc;
gint32 tag;
volatile gboolean failed;
- gboolean is_t125;
/*
* We must catch all the "ran past the end of the packet" exceptions
* here and, if we catch one, just return FALSE. It's too painful
* to have a version of dissect_per_sequence() that checks all
* references to the tvbuff before making them and returning "no"
* if they would fail.
*/
failed = FALSE;
TRY {
- /*
- * Check that the first byte of the packet is a valid t125/MCS header.
- * This might not be enough, but since t125 only catch COTP packets,
- * it should not be a problem.
- */
- guint8 first_byte = tvb_get_guint8(tvb, 0) >> 2;
- switch (first_byte) {
- case HF_T125_ERECT_DOMAIN_REQUEST:
- case HF_T125_ATTACH_USER_REQUEST:
- case HF_T125_ATTACH_USER_CONFIRM:
- case HF_T125_CHANNEL_JOIN_REQUEST:
- case HF_T125_CHANNEL_JOIN_CONFIRM:
- case HF_T125_DISCONNECT_PROVIDER_ULTIMATUM:
- case HF_T125_SEND_DATA_REQUEST:
- case HF_T125_SEND_DATA_INDICATION:
- is_t125 = TRUE;
- break;
- default:
- is_t125 = FALSE;
- break;
- }
- if(is_t125) {
- dissect_t125(tvb, pinfo, parent_tree, NULL);
- return TRUE;
- }
-
/* could be BER */
get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);
} CATCH_BOUNDS_ERRORS {
failed = TRUE;
} ENDTRY;
- /* is this strong enough ? */
- if (!failed && ((ber_class==BER_CLASS_APP) && ((tag>=101) && (tag<=104)))) {
+ if (failed) {
+ return FALSE;
+ }
+
+ if (((ber_class==BER_CLASS_APP) && ((tag>=101) && (tag<=104)))) {
dissect_t125(tvb, pinfo, parent_tree, NULL);
return TRUE;
}
+ /*
+ * Check that the first byte of the packet is a valid t125/MCS header.
+ * This might not be enough, but since t125 only catch COTP packets,
+ * it should not be a problem.
+ */
+ guint8 first_byte = tvb_get_guint8(tvb, 0) >> 2;
+ switch (first_byte) {
+ case HF_T125_ERECT_DOMAIN_REQUEST:
+ case HF_T125_ATTACH_USER_REQUEST:
+ case HF_T125_ATTACH_USER_CONFIRM:
+ case HF_T125_CHANNEL_JOIN_REQUEST:
+ case HF_T125_CHANNEL_JOIN_CONFIRM:
+ case HF_T125_DISCONNECT_PROVIDER_ULTIMATUM:
+ case HF_T125_SEND_DATA_REQUEST:
+ case HF_T125_SEND_DATA_INDICATION:
+ dissect_t125(tvb, pinfo, parent_tree, NULL);
+ return TRUE;
+ }
+
return FALSE;
}
/*--- proto_register_t125 -------------------------------------------*/
void proto_register_t125(void) {
/* List of fields */
static hf_register_info hf[] = {
/*--- Included file: packet-t125-hfarr.c ---*/
#line 1 "./asn1/t125/packet-t125-hfarr.c"
{ &hf_t125_ConnectMCSPDU_PDU,
{ "ConnectMCSPDU", "t125.ConnectMCSPDU",
FT_UINT32, BASE_DEC, VALS(t125_ConnectMCSPDU_vals), 0,
NULL, HFILL }},
{ &hf_t125_maxChannelIds,
{ "maxChannelIds", "t125.maxChannelIds",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_maxUserIds,
{ "maxUserIds", "t125.maxUserIds",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_maxTokenIds,
{ "maxTokenIds", "t125.maxTokenIds",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_numPriorities,
{ "numPriorities", "t125.numPriorities",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_minThroughput,
{ "minThroughput", "t125.minThroughput",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_maxHeight,
{ "maxHeight", "t125.maxHeight",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_maxMCSPDUsize,
{ "maxMCSPDUsize", "t125.maxMCSPDUsize",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_protocolVersion,
{ "protocolVersion", "t125.protocolVersion",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_callingDomainSelector,
{ "callingDomainSelector", "t125.callingDomainSelector",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_t125_calledDomainSelector,
{ "calledDomainSelector", "t125.calledDomainSelector",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_t125_upwardFlag,
{ "upwardFlag", "t125.upwardFlag",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t125_targetParameters,
{ "targetParameters", "t125.targetParameters_element",
FT_NONE, BASE_NONE, NULL, 0,
"DomainParameters", HFILL }},
{ &hf_t125_minimumParameters,
{ "minimumParameters", "t125.minimumParameters_element",
FT_NONE, BASE_NONE, NULL, 0,
"DomainParameters", HFILL }},
{ &hf_t125_maximumParameters,
{ "maximumParameters", "t125.maximumParameters_element",
FT_NONE, BASE_NONE, NULL, 0,
"DomainParameters", HFILL }},
{ &hf_t125_userData,
{ "userData", "t125.userData",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t125_result,
{ "result", "t125.result",
FT_UINT32, BASE_DEC, VALS(t125_Result_vals), 0,
NULL, HFILL }},
{ &hf_t125_calledConnectId,
{ "calledConnectId", "t125.calledConnectId",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t125_domainParameters,
{ "domainParameters", "t125.domainParameters_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t125_userData_01,
{ "userData", "t125.userData",
FT_BYTES, BASE_NONE, NULL, 0,
"T_userData_01", HFILL }},
{ &hf_t125_dataPriority,
{ "dataPriority", "t125.dataPriority",
FT_UINT32, BASE_DEC, VALS(t125_DataPriority_vals), 0,
NULL, HFILL }},
{ &hf_t125_connect_initial,
{ "connect-initial", "t125.connect_initial_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t125_connect_response,
{ "connect-response", "t125.connect_response_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t125_connect_additional,
{ "connect-additional", "t125.connect_additional_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t125_connect_result,
{ "connect-result", "t125.connect_result_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
/*--- End of included file: packet-t125-hfarr.c ---*/
-#line 151 "./asn1/t125/packet-t125-template.c"
+#line 146 "./asn1/t125/packet-t125-template.c"
};
/* List of subtrees */
static gint *ett[] = {
&ett_t125,
/*--- Included file: packet-t125-ettarr.c ---*/
#line 1 "./asn1/t125/packet-t125-ettarr.c"
&ett_t125_DomainParameters,
&ett_t125_Connect_Initial_U,
&ett_t125_Connect_Response_U,
&ett_t125_Connect_Additional_U,
&ett_t125_Connect_Result_U,
&ett_t125_ConnectMCSPDU,
/*--- End of included file: packet-t125-ettarr.c ---*/
-#line 157 "./asn1/t125/packet-t125-template.c"
+#line 152 "./asn1/t125/packet-t125-template.c"
};
/* Register protocol */
proto_t125 = proto_register_protocol(PNAME, PSNAME, PFNAME);
/* Register fields and subtrees */
proto_register_field_array(proto_t125, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
t125_heur_subdissector_list= register_heur_dissector_list("t125", proto_t125);
register_dissector("t125", dissect_t125, proto_t125);
}
/*--- proto_reg_handoff_t125 ---------------------------------------*/