aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tpncp.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2012-11-11 20:54:12 +0000
committerEvan Huus <eapache@gmail.com>2012-11-11 20:54:12 +0000
commit693217ca6bfaeee75714514563ad6f5ab0cb308d (patch)
tree37554e34a35384b85d26ba56a1f078a7b38ba1ce /epan/dissectors/packet-tpncp.c
parent1bcc30de17ca94ebbe847c6cf3835a6cf849856f (diff)
Fix the rest of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6665
Catch exceptions thrown while registering the dynamically generated tpncp fields, and take that as a hint that the .dat file is corrupt. svn path=/trunk/; revision=46004
Diffstat (limited to 'epan/dissectors/packet-tpncp.c')
-rw-r--r--epan/dissectors/packet-tpncp.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c
index 7a5524ee62..6ed5720e84 100644
--- a/epan/dissectors/packet-tpncp.c
+++ b/epan/dissectors/packet-tpncp.c
@@ -36,6 +36,7 @@
#include <wsutil/file_util.h>
+#include <epan/exceptions.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/emem.h>
@@ -766,14 +767,27 @@ void proto_register_tpncp(void) {
proto_tpncp = proto_register_protocol("AudioCodes TPNCP (TrunkPack Network Control Protocol)",
"TPNCP", "tpncp");
- /*
- * The function proto_register_field_array can not work with dynamic arrays,
- * so passing dynamic array elements one-by-one in the loop.
+ /* Rather than duplicating large quantities of code from
+ * proto_register_field_array() and friends to sanitize the tpncp.dat file
+ * when we read it, just catch any exceptions we get while registering and
+ * take them as a hint that the file is corrupt. Then move on, so that at
+ * least the rest of the protocol dissectors will still work.
*/
- for(idx = 0; idx < hf_size; idx++) {
- proto_register_field_array(proto_tpncp, &hf[idx], 1);
+ TRY {
+ /* The function proto_register_field_array does not work with dynamic
+ * arrays, so pass dynamic array elements one-by-one in the loop.
+ */
+ for(idx = 0; idx < hf_size; idx++) {
+ proto_register_field_array(proto_tpncp, &hf[idx], 1);
+ }
+ }
+
+ CATCH_ALL {
+ g_warning("Corrupt tpncp.dat file, tpncp dissector will not work.");
}
+ ENDTRY;
+
proto_register_subtree_array(ett, array_length(ett));
register_dissector("tpncp", dissect_tpncp, proto_tpncp);