diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-12-31 20:35:55 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-12-31 20:35:55 +0000 |
commit | 16a61cc9c068f03ae5faf9e59dd7b185a3056b29 (patch) | |
tree | 186d7b3f11227a24c5ea0d40200813847cc37e84 /epan/dissectors/packet-fcfcs.c | |
parent | 9e0391990ea6e2a3e9ff08d3d648b40f8dfc5ec7 (diff) |
Note what Fibre Channel spec documents this protocol.
Don't assign the const pointers passed to hash routines to non-const
pointers.
Don't assume that strings the spec says are null-terminated are
necessarily null-terminated in the packet - use "tvb_strsize()" to find
the length of the purported null-terminated string; it'll throw the
appropriate exception if no null is found.
svn path=/trunk/; revision=12904
Diffstat (limited to 'epan/dissectors/packet-fcfcs.c')
-rw-r--r-- | epan/dissectors/packet-fcfcs.c | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/epan/dissectors/packet-fcfcs.c b/epan/dissectors/packet-fcfcs.c index 179e9f1e66..09384be15c 100644 --- a/epan/dissectors/packet-fcfcs.c +++ b/epan/dissectors/packet-fcfcs.c @@ -58,6 +58,10 @@ #include "packet-fcct.h" #include "packet-fcfcs.h" +/* + * See the FC-GS3 specification. + */ + /* Initialize the protocol and registered fields */ static int proto_fcfcs = -1; static int hf_fcs_opcode = -1; @@ -117,8 +121,8 @@ static dissector_handle_t data_handle; static gint fcfcs_equal(gconstpointer v, gconstpointer w) { - fcfcs_conv_key_t *v1 = (fcfcs_conv_key_t *)v; - fcfcs_conv_key_t *v2 = (fcfcs_conv_key_t *)w; + const fcfcs_conv_key_t *v1 = v; + const fcfcs_conv_key_t *v2 = w; return (v1->conv_idx == v2->conv_idx); } @@ -126,7 +130,7 @@ fcfcs_equal(gconstpointer v, gconstpointer w) static guint fcfcs_hash (gconstpointer v) { - fcfcs_conv_key_t *key = (fcfcs_conv_key_t *)v; + const fcfcs_conv_key_t *key = v; guint val; val = key->conv_idx; @@ -299,7 +303,6 @@ static void dissect_fcfcs_gieil (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) { int offset = 16; /* past the fcct header */ - gchar *str; int len, tot_len, prevlen; if (tree) { @@ -313,43 +316,28 @@ dissect_fcfcs_gieil (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) tot_len); prevlen = 0; - str = (gchar *)tvb_get_ptr (tvb, offset+4, tot_len); - len = strlen (str); - if (len) { - proto_tree_add_item (tree, hf_fcs_vendorname, tvb, offset+4, - len, 0); - } - - prevlen += (len+1); - str = (gchar *)tvb_get_ptr (tvb, offset+4+prevlen, tot_len-prevlen); - len = strlen (str); - - if (len) { - proto_tree_add_item (tree, hf_fcs_modelname, tvb, offset+4+prevlen, - len, 0); - } - - prevlen += (len+1); - str = (gchar *)tvb_get_ptr (tvb, offset+4+prevlen, tot_len-prevlen); - len = strlen (str); - - if (len) { - proto_tree_add_item (tree, hf_fcs_releasecode, tvb, - offset+4+prevlen, len, 0); - } - - prevlen += (len+1); + len = tvb_strsize(tvb, offset+4); + proto_tree_add_item (tree, hf_fcs_vendorname, tvb, offset+4, + len, FALSE); + prevlen += len; + + len = tvb_strsize(tvb, offset+4+prevlen); + proto_tree_add_item (tree, hf_fcs_modelname, tvb, offset+4+prevlen, + len, FALSE); + prevlen += len; + + len = tvb_strsize(tvb, offset+4+prevlen); + proto_tree_add_item (tree, hf_fcs_releasecode, tvb, + offset+4+prevlen, len, FALSE); + prevlen += len; offset += (4+prevlen); while (tot_len > prevlen) { - str = (gchar *)tvb_get_ptr (tvb, offset, tot_len-prevlen); - len = strlen (str); - if (len) { - proto_tree_add_text (tree, tvb, offset, len, - "Vendor-specific Information: %s", - str); - } - prevlen += (len+1); - offset += (len+1); + len = tvb_strsize(tvb, offset); + proto_tree_add_text (tree, tvb, offset, len, + "Vendor-specific Information: %s", + tvb_format_text(tvb, offset, len-1)); + prevlen += len; + offset += len; } } } @@ -1181,4 +1169,3 @@ proto_reg_handoff_fcfcs (void) data_handle = find_dissector ("data"); } - |