diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2015-08-26 22:52:06 +0200 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2015-08-26 20:57:09 +0000 |
commit | 8ad56117502207d95d54bd2c8dff24d001530d24 (patch) | |
tree | a5f81a1b78b234181ba4f5bc0b5e7fc97c6e7332 | |
parent | 7b35992b7a15ad2306d23c9f2a66199a7f8ea975 (diff) |
sv: remove some unnecessary checks
http://personal.strath.ac.uk/robert.c.atkinson/papers/sgms2011.pdf
implies that appid, length and the two reserved fields are mandatory
just try to dissect them, don't check if there's enough bytes remaining
correct a typo while at it
Change-Id: I09a315fc2c70161af527dca5661f877e09b63ff6
Reviewed-on: https://code.wireshark.org/review/10273
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
-rw-r--r-- | asn1/sv/packet-sv-template.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-sv.c | 20 |
2 files changed, 14 insertions, 22 deletions
diff --git a/asn1/sv/packet-sv-template.c b/asn1/sv/packet-sv-template.c index 3a13b50aef..5403d02df9 100644 --- a/asn1/sv/packet-sv-template.c +++ b/asn1/sv/packet-sv-template.c @@ -1,5 +1,5 @@ /* packet-sv.c - * Routines for IEC 61850 Sampled Vales packet dissection + * Routines for IEC 61850 Sampled Values packet dissection * Michael Bernhard 2008 * * Wireshark - Network traffic analyzer @@ -113,23 +113,19 @@ dissect_sv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) col_clear(pinfo->cinfo, COL_INFO); /* APPID */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 2) - proto_tree_add_item(tree, hf_sv_appid, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_appid, tvb, offset, 2, ENC_BIG_ENDIAN); /* Length */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 4) - proto_tree_add_item(tree, hf_sv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN); /* Reserved 1 */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 6) - proto_tree_add_item(tree, hf_sv_reserve1, tvb, offset + 4, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_reserve1, tvb, offset + 4, 2, ENC_BIG_ENDIAN); /* Reserved 2 */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 8) - proto_tree_add_item(tree, hf_sv_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN); offset = 8; - while (tree && tvb_reported_length_remaining(tvb, offset) > 0){ + while (tvb_reported_length_remaining(tvb, offset) > 0){ old_offset = offset; offset = dissect_sv_SampledValues(FALSE, tvb, offset, &asn1_ctx , tree, -1); if (offset == old_offset) { diff --git a/epan/dissectors/packet-sv.c b/epan/dissectors/packet-sv.c index 6652a75387..8986fc4183 100644 --- a/epan/dissectors/packet-sv.c +++ b/epan/dissectors/packet-sv.c @@ -7,7 +7,7 @@ #line 1 "../../asn1/sv/packet-sv-template.c" /* packet-sv.c - * Routines for IEC 61850 Sampled Vales packet dissection + * Routines for IEC 61850 Sampled Values packet dissection * Michael Bernhard 2008 * * Wireshark - Network traffic analyzer @@ -363,23 +363,19 @@ dissect_sv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) col_clear(pinfo->cinfo, COL_INFO); /* APPID */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 2) - proto_tree_add_item(tree, hf_sv_appid, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_appid, tvb, offset, 2, ENC_BIG_ENDIAN); /* Length */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 4) - proto_tree_add_item(tree, hf_sv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN); /* Reserved 1 */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 6) - proto_tree_add_item(tree, hf_sv_reserve1, tvb, offset + 4, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_reserve1, tvb, offset + 4, 2, ENC_BIG_ENDIAN); /* Reserved 2 */ - if (tree && tvb_reported_length_remaining(tvb, offset) >= 8) - proto_tree_add_item(tree, hf_sv_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_sv_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN); offset = 8; - while (tree && tvb_reported_length_remaining(tvb, offset) > 0){ + while (tvb_reported_length_remaining(tvb, offset) > 0){ old_offset = offset; offset = dissect_sv_SampledValues(FALSE, tvb, offset, &asn1_ctx , tree, -1); if (offset == old_offset) { @@ -513,7 +509,7 @@ void proto_register_sv(void) { NULL, HFILL }}, /*--- End of included file: packet-sv-hfarr.c ---*/ -#line 210 "../../asn1/sv/packet-sv-template.c" +#line 206 "../../asn1/sv/packet-sv-template.c" }; /* List of subtrees */ @@ -530,7 +526,7 @@ void proto_register_sv(void) { &ett_sv_ASDU, /*--- End of included file: packet-sv-ettarr.c ---*/ -#line 218 "../../asn1/sv/packet-sv-template.c" +#line 214 "../../asn1/sv/packet-sv-template.c" }; static ei_register_info ei[] = { |