diff options
Diffstat (limited to 'epan/dissectors/packet-tpncp.c')
-rw-r--r-- | epan/dissectors/packet-tpncp.c | 24 |
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); |