aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-sctp.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2011-01-11 22:36:31 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2011-01-11 22:36:31 +0000
commit6e7d85a92cd4c3549e2e6d6c3c456596f111a68b (patch)
tree1fb4dbdda87e85e9e445a809e6859bf400ebf081 /epan/dissectors/packet-sctp.c
parenta78e5d7900df0b2745a7e6aa797eaf9d227d9f94 (diff)
Don't store message fragments whose length is 0: there's no point. (Otherwise
fragment->len was left unitialized.) Also (unrelated): save a couple of calls to tvb_reported_length() since the value is already stored in a variable. svn path=/trunk/; revision=35485
Diffstat (limited to 'epan/dissectors/packet-sctp.c')
-rw-r--r--epan/dissectors/packet-sctp.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index d966e89701..a44b6b5e4d 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -2194,16 +2194,18 @@ add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
}
}
+ /* There is no point in storing a fragment with no data in it */
+ if (tvb_length(tvb) == 0)
+ return NULL;
+
/* create new fragment */
fragment = g_malloc (sizeof (sctp_fragment));
fragment->frame_num = pinfo->fd->num;
fragment->tsn = tsn;
fragment->len = tvb_length(tvb);
fragment->next = NULL;
- if (fragment->len) {
- fragment->data = g_malloc (fragment->len);
- tvb_memcpy(tvb, fragment->data, 0, fragment->len);
- }
+ fragment->data = g_malloc (fragment->len);
+ tvb_memcpy(tvb, fragment->data, 0, fragment->len);
/* add new fragment to linked list. sort ascending by tsn */
if (!msg->fragments)
@@ -3549,18 +3551,18 @@ dissect_sctp_chunk(tvbuff_t *chunk_tvb,
result = FALSE;
/* first extract the chunk header */
- type = tvb_get_guint8(chunk_tvb, CHUNK_TYPE_OFFSET);
- flags = tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET);
- length = tvb_get_ntohs(chunk_tvb, CHUNK_LENGTH_OFFSET);
- padding_length = tvb_reported_length(chunk_tvb) - length;
+ type = tvb_get_guint8(chunk_tvb, CHUNK_TYPE_OFFSET);
+ flags = tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET);
+ length = tvb_get_ntohs(chunk_tvb, CHUNK_LENGTH_OFFSET);
reported_length = tvb_reported_length(chunk_tvb);
+ padding_length = reported_length - length;
if (useinfo)
col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(type, chunk_type_values, "RESERVED"));
if (tree) {
/* create proto_tree stuff */
- chunk_item = proto_tree_add_text(sctp_tree, chunk_tvb, CHUNK_HEADER_OFFSET, tvb_reported_length(chunk_tvb), "%s chunk", val_to_str(type, chunk_type_values, "RESERVED"));
+ chunk_item = proto_tree_add_text(sctp_tree, chunk_tvb, CHUNK_HEADER_OFFSET, reported_length, "%s chunk", val_to_str(type, chunk_type_values, "RESERVED"));
chunk_tree = proto_item_add_subtree(chunk_item, ett_sctp_chunk);
/* then insert the chunk header components into the protocol tree */