PER: Check length calling tvb_new_octet_aligned()

Fix calling tvb_new_octet_aligned() with length == 0

Related to #17890 case 17
This commit is contained in:
Uli Heilmeier 2022-02-05 15:29:46 +01:00 committed by A Wireshark GitLab Utility
parent 833a825c7c
commit 782e7db8c0
1 changed files with 9 additions and 0 deletions

View File

@ -1004,6 +1004,9 @@ dissect_per_any_oid(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree
DEBUG_ENTRY("dissect_per_any_oid");
offset = dissect_per_length_determinant(tvb, offset, actx, tree, hf_per_object_identifier_length, &length, NULL);
if(length == 0){
dissect_per_not_decoded_yet(tree, actx->pinfo, tvb, "unexpected length");
}
if (actx->aligned) BYTE_ALIGN_OFFSET(offset);
val_tvb = tvb_new_octet_aligned(tvb, offset, length * 8);
/* Add new data source if the offet was unaligned */
@ -1672,6 +1675,9 @@ dissect_per_real(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tr
double val = 0;
offset = dissect_per_length_determinant(tvb, offset, actx, tree, hf_per_real_length, &val_length, NULL);
if(val_length == 0){
dissect_per_not_decoded_yet(tree, actx->pinfo, tvb, "unexpected length");
}
if (actx->aligned) BYTE_ALIGN_OFFSET(offset);
val_tvb = tvb_new_octet_aligned(tvb, offset, val_length * 8);
/* Add new data source if the offet was unaligned */
@ -2699,6 +2705,9 @@ call_per_oid_callback(const char *oid, tvbuff_t *tvb, packet_info *pinfo, proto_
start_offset = offset;
offset = dissect_per_length_determinant(tvb, offset, actx, tree, hf_per_open_type_length, &type_length, NULL);
if(type_length == 0){
dissect_per_not_decoded_yet(tree, actx->pinfo, tvb, "unexpected length");
}
if (actx->aligned) BYTE_ALIGN_OFFSET(offset);
end_offset = offset + type_length;