forked from osmocom/wireshark
throw the new FieldError exception, if a dissector tries to add a field with invalid parameters
add a message parameter to the show_exception function svn path=/trunk/; revision=13074
This commit is contained in:
parent
491ceb3905
commit
1c9781b4ec
|
@ -228,7 +228,7 @@ call_app_dissector(tvbuff_t *tvb, gint offset, gint param_len,
|
|||
}
|
||||
CATCH_ALL
|
||||
{
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE);
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
|
||||
}
|
||||
ENDTRY;
|
||||
}
|
||||
|
|
|
@ -2108,7 +2108,7 @@ else
|
|||
} CATCH(BoundsError) {
|
||||
RETHROW;
|
||||
} CATCH_ALL {
|
||||
show_exception(decrypted_tvb, pinfo, tree, EXCEPT_CODE);
|
||||
show_exception(decrypted_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
|
||||
} ENDTRY;
|
||||
}
|
||||
|
||||
|
@ -2168,7 +2168,7 @@ dissect_dcerpc_verifier (tvbuff_t *tvb, packet_info *pinfo,
|
|||
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,
|
||||
|
@ -2269,7 +2269,7 @@ dissect_dcerpc_cn_auth (tvbuff_t *tvb, int stub_offset, packet_info *pinfo,
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
}
|
||||
}
|
||||
CATCH_ALL {
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE);
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
|
||||
}
|
||||
ENDTRY;
|
||||
|
||||
|
@ -206,7 +206,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
|
||||
void
|
||||
show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||
unsigned long exception)
|
||||
unsigned long exception, const char *exception_message)
|
||||
{
|
||||
switch (exception) {
|
||||
|
||||
|
@ -220,6 +220,18 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* 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
|
||||
|
|
|
@ -102,7 +102,7 @@ dissect_802_3(int length, gboolean is_802_2, tvbuff_t *tvb,
|
|||
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;
|
||||
|
|
|
@ -287,7 +287,7 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len)
|
|||
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;
|
||||
|
|
|
@ -242,7 +242,7 @@ call_acse_dissector(tvbuff_t *tvb, gint offset, gint param_len,
|
|||
}
|
||||
CATCH_ALL
|
||||
{
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE);
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
|
||||
}
|
||||
ENDTRY;
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ call_pres_dissector(tvbuff_t *tvb, int offset, guint16 param_len,
|
|||
}
|
||||
CATCH_ALL
|
||||
{
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE);
|
||||
show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
|
||||
}
|
||||
ENDTRY;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#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:
|
||||
*
|
||||
|
|
|
@ -2002,6 +2002,7 @@ alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|||
{
|
||||
header_field_info *hfinfo;
|
||||
field_info *fi;
|
||||
gchar *error_descr;
|
||||
|
||||
/*
|
||||
* We only allow a null tvbuff if the item has a zero length,
|
||||
|
@ -2092,7 +2093,11 @@ alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue