diff options
author | Brian Sipos <brian.sipos@gmail.com> | 2022-10-16 17:30:19 -0400 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2022-10-19 15:27:42 +0000 |
commit | 5bb756e203539c7fd3bb6c16dd845e42a347a982 (patch) | |
tree | 87dca3b98b1766a7fae046bbffc3ec9343dd57fc /epan/proto.c | |
parent | d2e5bd80cbc5c29f6a33dc6678baeaa4fd358c64 (diff) |
epan: centralize SDNV processing along other similar varint types
This avoids having general-purpose decoding happening in
non-DLL-exported functions defined in a dissector for #18478,
and removes unused functions and avoids duplicate decoding.
This also removes unnecessary early exit conditions for #18145.
Unit test cases for varint decoding are added to verify this.
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/epan/proto.c b/epan/proto.c index 29f491ff3f..387b0052df 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -3199,7 +3199,7 @@ proto_tree_add_item_ret_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_tree_set_uint(new_fi, value); new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; - if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG)) { + if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG|ENC_VARINT_SDNV)) { new_fi->flags |= FI_VARINT; } return proto_tree_add_node(tree, new_fi); @@ -3491,7 +3491,7 @@ proto_tree_add_item_ret_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_tree_set_uint64(new_fi, value); new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; - if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG)) { + if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG|ENC_VARINT_SDNV)) { new_fi->flags |= FI_VARINT; } @@ -3551,7 +3551,7 @@ proto_tree_add_item_ret_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_tree_set_int64(new_fi, value); new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; - if (encoding & (ENC_VARINT_PROTOBUF | ENC_VARINT_ZIGZAG)) { + if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG|ENC_VARINT_SDNV)) { new_fi->flags |= FI_VARINT; } @@ -3608,7 +3608,7 @@ proto_tree_add_item_ret_varint(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_tree_set_uint64(new_fi, value); new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; - if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG)) { + if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG|ENC_VARINT_SDNV)) { new_fi->flags |= FI_VARINT; } @@ -6062,7 +6062,7 @@ get_hfi_length(header_field_info *hfinfo, tvbuff_t *tvb, const gint start, gint * of the string", and if the tvbuff if short, we just * throw an exception. * - * For ENC_VARINT_PROTOBUF|ENC_VARINT_QUIC|ENC_VARIANT_ZIGZAG, it means "find the end of the string", + * For ENC_VARINT_PROTOBUF|ENC_VARINT_QUIC|ENC_VARIANT_ZIGZAG|ENC_VARINT_SDNV, it means "find the end of the string", * and if the tvbuff if short, we just throw an exception. * * It's not valid for any other type of field. For those @@ -6073,7 +6073,7 @@ get_hfi_length(header_field_info *hfinfo, tvbuff_t *tvb, const gint start, gint * Length would run past the end of the packet. */ if ((IS_FT_INT(hfinfo->type)) || (IS_FT_UINT(hfinfo->type))) { - if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG)) { + if (encoding & (ENC_VARINT_PROTOBUF|ENC_VARINT_ZIGZAG|ENC_VARINT_SDNV)) { /* * Leave the length as -1, so our caller knows * it was -1. |