diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-08-07 20:38:11 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-08-08 03:39:08 +0000 |
commit | 20c0fffc922e09cbb0dbd4317080d3f9ed6a9cae (patch) | |
tree | ec38eb9750ca7d77dbc545bdb738487547022402 /epan/dissectors/packet-iscsi.c | |
parent | c10396dbbf782a576bc1f9a931cf86090cec3878 (diff) |
Wrap some tvb_get_ptr calls in crc32c_tvb_offset_calculate().
This eliminates some tvb_get_ptr calls from dissectors, as part of
trying to minimize if not eliminate its use in dissectors (it's a bit of
what's called an "attractive nuisance", in that users who don't
understand what it does - and doesn't! - do may use it in ways that are
unsafe, e.g. thinking you can use it to get a null-terminated string
from a packet).
It also eliminates the possibility of passing one length to
tvb_get_ptr() and another to crc32c_calculate().
Change-Id: I8a07168d0bc088b45d607e00c5bb1d98421ebc73
Reviewed-on: https://code.wireshark.org/review/3488
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-iscsi.c')
-rw-r--r-- | epan/dissectors/packet-iscsi.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index 956df5d6d1..280706c7d7 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -44,6 +44,7 @@ #include "packet-scsi.h" #include <epan/wmem/wmem.h> #include <epan/range.h> +#include <epan/crc32-tvb.h> #include <wsutil/crc32.h> void proto_register_iscsi(void); @@ -634,7 +635,7 @@ handleHeaderDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb switch(iscsi_session->header_digest){ case ISCSI_DIGEST_CRC32: if(available_bytes >= (headerLen + 4)) { - guint32 crc = ~crc32c_calculate(tvb_get_ptr(tvb, offset, headerLen), headerLen, CRC32C_PRELOAD); + guint32 crc = ~crc32c_tvb_offset_calculate(tvb, offset, headerLen, CRC32C_PRELOAD); guint32 sent = tvb_get_ntohl(tvb, offset + headerLen); if(crc == sent) { proto_tree_add_uint_format_value(ti, hf_iscsi_HeaderDigest32, tvb, offset + headerLen, 4, sent, "0x%08x (Good CRC32)", sent); @@ -657,7 +658,7 @@ handleDataDigest(iscsi_session_t *iscsi_session, proto_item *ti, tvbuff_t *tvb, switch (iscsi_session->data_digest){ case ISCSI_DIGEST_CRC32: if(available_bytes >= (dataLen + 4)) { - guint32 crc = ~crc32c_calculate(tvb_get_ptr(tvb, offset, dataLen), dataLen, CRC32C_PRELOAD); + guint32 crc = ~crc32c_tvb_offset_calculate(tvb, offset, dataLen, CRC32C_PRELOAD); guint32 sent = tvb_get_ntohl(tvb, offset + dataLen); if(crc == sent) { proto_tree_add_uint_format_value(ti, hf_iscsi_DataDigest32, tvb, offset + dataLen, 4, sent, "0x%08x (Good CRC32)", sent); @@ -2357,7 +2358,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec (iscsi_session->header_digest == ISCSI_DIGEST_AUTO)) { guint32 crc; /* we have enough data to test if HeaderDigest is enabled */ - crc= ~crc32c_calculate(tvb_get_ptr(tvb, offset, 48+ahsLen*4), 48+ahsLen*4, CRC32C_PRELOAD); + crc= ~crc32c_tvb_offset_calculate(tvb, offset, 48+ahsLen*4, CRC32C_PRELOAD); if(crc==tvb_get_ntohl(tvb,48+ahsLen*4)){ iscsi_session->header_digest = ISCSI_DIGEST_CRC32; } else { @@ -2390,7 +2391,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec (iscsi_session->data_digest == ISCSI_DIGEST_AUTO)) { guint32 crc; /* we have enough data to test if DataDigest is enabled */ - crc = ~crc32c_calculate(tvb_get_ptr(tvb, data_segment_offset, data_segment_len_padded), data_segment_len_padded, CRC32C_PRELOAD); + crc = ~crc32c_tvb_offset_calculate(tvb, data_segment_offset, data_segment_len_padded, CRC32C_PRELOAD); if (crc == tvb_get_ntohl(tvb, data_segment_offset + data_segment_len_padded)) { iscsi_session->data_digest = ISCSI_DIGEST_CRC32; } else { |