aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>2005-01-16 16:06:15 +0000
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>2005-01-16 16:06:15 +0000
commit694c3b39b30543db5af84695012146ff79b473c3 (patch)
treed5c476ab5cc45bb308d2bf464913b3d7805504c2
parent288b9a0662df2cf3444bf16da328b972b3daa364 (diff)
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 git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13074 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--epan/dissectors/packet-acse.c2
-rw-r--r--epan/dissectors/packet-dcerpc.c6
-rw-r--r--epan/dissectors/packet-ethertype.c2
-rw-r--r--epan/dissectors/packet-frame.c16
-rw-r--r--epan/dissectors/packet-frame.h2
-rw-r--r--epan/dissectors/packet-ieee8023.c2
-rw-r--r--epan/dissectors/packet-isl.c2
-rw-r--r--epan/dissectors/packet-pres.c2
-rw-r--r--epan/dissectors/packet-ses.c2
-rw-r--r--epan/exceptions.h1
-rw-r--r--epan/proto.c7
11 files changed, 31 insertions, 13 deletions
diff --git a/epan/dissectors/packet-acse.c b/epan/dissectors/packet-acse.c
index da96e6c636..1ba1eb52ea 100644
--- a/epan/dissectors/packet-acse.c
+++ b/epan/dissectors/packet-acse.c
@@ -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;
}
diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c
index 33860a8c58..8f378322eb 100644
--- a/epan/dissectors/packet-dcerpc.c
+++ b/epan/dissectors/packet-dcerpc.c
@@ -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;
}
}
diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c
index 93933100be..60a058c3c0 100644
--- a/epan/dissectors/packet-ethertype.c
+++ b/epan/dissectors/packet-ethertype.c
@@ -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;
}
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index 29efbc76c5..0716595f72 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -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();
}
}
diff --git a/epan/dissectors/packet-frame.h b/epan/dissectors/packet-frame.h
index f5a135956b..1430fb1544 100644
--- a/epan/dissectors/packet-frame.h
+++ b/epan/dissectors/packet-frame.h
@@ -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
diff --git a/epan/dissectors/packet-ieee8023.c b/epan/dissectors/packet-ieee8023.c
index 5e8f98aa2d..55853d9d15 100644
--- a/epan/dissectors/packet-ieee8023.c
+++ b/epan/dissectors/packet-ieee8023.c
@@ -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;
diff --git a/epan/dissectors/packet-isl.c b/epan/dissectors/packet-isl.c
index c1544dc611..44e099de55 100644
--- a/epan/dissectors/packet-isl.c
+++ b/epan/dissectors/packet-isl.c
@@ -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;
diff --git a/epan/dissectors/packet-pres.c b/epan/dissectors/packet-pres.c
index d12218316e..b692101ae7 100644
--- a/epan/dissectors/packet-pres.c
+++ b/epan/dissectors/packet-pres.c
@@ -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;
}
diff --git a/epan/dissectors/packet-ses.c b/epan/dissectors/packet-ses.c
index b7e792769a..fe34919adf 100644
--- a/epan/dissectors/packet-ses.c
+++ b/epan/dissectors/packet-ses.c
@@ -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;
}
diff --git a/epan/exceptions.h b/epan/exceptions.h
index a16b892565..343794382e 100644
--- a/epan/exceptions.h
+++ b/epan/exceptions.h
@@ -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:
*
diff --git a/epan/proto.c b/epan/proto.c
index 58538d49cb..100e7dd138 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -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);