}
CATCH_ALL
{
- show_exception(tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
}
ENDTRY;
}
} CATCH(BoundsError) {
RETHROW;
} CATCH_ALL {
- show_exception(decrypted_tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(decrypted_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
} ENDTRY;
}
dissect_auth_verf(auth_tvb, pinfo, dcerpc_tree, auth_fns,
hdr, auth_info);
} CATCH_ALL {
- show_exception(auth_tvb, pinfo, dcerpc_tree, EXCEPT_CODE);
+ show_exception(auth_tvb, pinfo, dcerpc_tree, EXCEPT_CODE, GET_MESSAGE);
} ENDTRY;
} else {
proto_tree_add_text (dcerpc_tree, auth_tvb, 0, hdr->auth_len,
padding is actually inside the encrypted stub */
auth_info->auth_size = hdr->auth_len + 8;
} CATCH_ALL {
- show_exception(tvb, pinfo, dcerpc_tree, EXCEPT_CODE);
+ show_exception(tvb, pinfo, dcerpc_tree, EXCEPT_CODE, GET_MESSAGE);
} ENDTRY;
}
}
to show the trailer, after noting that a dissector was
found and restoring the protocol value that was in effect
before we called the subdissector. */
- show_exception(next_tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(next_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
dissector_found = TRUE;
pinfo->current_proto = saved_proto;
}
}
}
CATCH_ALL {
- show_exception(tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
}
ENDTRY;
void
show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- unsigned long exception)
+ unsigned long exception, const char *exception_message)
{
switch (exception) {
case ReportedBoundsError:
show_reported_bounds_error(tvb, pinfo, tree);
break;
+ case FieldError:
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_str(pinfo->cinfo, COL_INFO, "[Dissector Bug]");
+ proto_tree_add_protocol_format(tree, proto_malformed, tvb, 0, 0,
+ "[FieldError: %s]", exception_message);
+ g_warning("FieldError in packet: %u (%s)", pinfo->fd->num, exception_message);
+ if(exception_message)
+ g_free( (void *) exception_message);
+ break;
+ default:
+ /* XXX - we want to know, if an unknown exception passed until here, don't we? */
+ g_assert_not_reached();
}
}
* Routine used to add an indication of an arbitrary exception to the tree.
*/
void show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- unsigned long exception);
+ unsigned long exception, const char *exception_message);
/*
* Routine used to add an indication of a ReportedBoundsError exception
Show the exception, and then drive on to show the trailer,
restoring the protocol value that was in effect before we
called the subdissector. */
- show_exception(next_tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(next_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
pinfo->current_proto = saved_proto;
}
ENDTRY;
Show the exception, and then drive on to show the trailer,
restoring the protocol value that was in effect before we
called the subdissector. */
- show_exception(next_tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(next_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
pinfo->current_proto = saved_proto;
}
ENDTRY;
}
CATCH_ALL
{
- show_exception(tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
}
ENDTRY;
}
}
CATCH_ALL
{
- show_exception(tvb, pinfo, tree, EXCEPT_CODE);
+ show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
}
ENDTRY;
}
#define BoundsError 1 /* Index is out of range */
#define ReportedBoundsError 2 /* Index is beyond reported length (not cap_len) */
#define TypeError 3 /* During dfilter parsing */
+#define FieldError 4 /* A buggy dissector tried to add a field with invalid parameters */
/* Usage:
*
{
header_field_info *hfinfo;
field_info *fi;
+ gchar *error_descr;
/*
* We only allow a null tvbuff if the item has a zero length,
g_assert_not_reached();
}
} else
- g_assert(*length >= 0);
+ if(*length < 0) {
+ error_descr = g_strdup_printf("\"%s\" - \"%s\" invalid length: %d %s/%u",
+ hfinfo->name, hfinfo->abbrev, *length, __FILE__, __LINE__);
+ THROW_MESSAGE(FieldError, error_descr);
+ }
FIELD_INFO_NEW(fi);