diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index bf0edfc64a..edc8704592 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -1576,8 +1576,8 @@ libwireshark.so.0 libwireshark0 #MINVER# tvb_new_composite@Base 1.9.1 tvb_new_octet_aligned@Base 1.9.1 tvb_new_real_data@Base 1.9.1 - tvb_new_subset@Base 1.9.1 tvb_new_subset_length@Base 1.9.1 + tvb_new_subset_length_caplen@Base 2.3.0 tvb_new_subset_remaining@Base 1.9.1 tvb_offset_exists@Base 1.9.1 tvb_offset_from_real_beginning@Base 1.9.1 diff --git a/doc/README.dissector b/doc/README.dissector index 39600c515e..3a722cb87f 100644 --- a/doc/README.dissector +++ b/doc/README.dissector @@ -2225,7 +2225,7 @@ that are relevant to the next dissector). The syntax for creating a new TVBUFF_SUBSET is: -next_tvb = tvb_new_subset(tvb, offset, length, reported_length) +next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, reported_length) or, in the common case where it should just run to the end of the packet, diff --git a/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc b/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc index df7c1b6eb3..88c01256bd 100644 --- a/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc +++ b/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc @@ -739,11 +739,11 @@ amount of parameters: if (new_tvb) { /* take it all */ next_tvb = new_tvb; } else { /* make a new subset */ - next_tvb = tvb_new_subset(tvb, offset, -1, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, -1); } } else { /* Not fragmented */ - next_tvb = tvb_new_subset(tvb, offset, -1, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, -1); } ..... diff --git a/epan/dissectors/asn1/cmp/packet-cmp-template.c b/epan/dissectors/asn1/cmp/packet-cmp-template.c index 68bd35d568..b76fa6b2d0 100644 --- a/epan/dissectors/asn1/cmp/packet-cmp-template.c +++ b/epan/dissectors/asn1/cmp/packet-cmp-template.c @@ -144,7 +144,7 @@ static int dissect_cmp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa switch(pdu_type){ case CMP_TYPE_PKIMSG: - next_tvb = tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); dissect_cmp_pdu(next_tvb, tree, &asn1_ctx); offset += tvb_reported_length_remaining(tvb, offset); break; @@ -172,12 +172,12 @@ static int dissect_cmp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa proto_tree_add_time(tcptrans_tree, hf_cmp_tcptrans_ttcb, tvb, offset, 4, &ts); offset += 4; - next_tvb = tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); dissect_cmp_pdu(next_tvb, tree, &asn1_ctx); offset += tvb_reported_length_remaining(tvb, offset); break; case CMP_TYPE_FINALMSGREP: - next_tvb = tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); dissect_cmp_pdu(next_tvb, tree, &asn1_ctx); offset += tvb_reported_length_remaining(tvb, offset); break; diff --git a/epan/dissectors/asn1/h225/h225.cnf b/epan/dissectors/asn1/h225/h225.cnf index 5cdad7956d..0aa4b15e36 100644 --- a/epan/dissectors/asn1/h225/h225.cnf +++ b/epan/dissectors/asn1/h225/h225.cnf @@ -865,7 +865,7 @@ H221NonStandard/manufacturerCode VAL_PTR = &manufacturerCode if (gefx) { ti = proto_tree_add_string(tree, hf_h225_debug_dissector_try_string, tvb, offset>>3, 0, gefx->key); PROTO_ITEM_SET_HIDDEN(ti); - dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); + dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset_length_caplen(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); } actx->private_data = gefx; /* subdissector could overwrite it */ #.END diff --git a/epan/dissectors/asn1/h245/h245.cnf b/epan/dissectors/asn1/h245/h245.cnf index 35d642f1cf..1d8f3e4595 100644 --- a/epan/dissectors/asn1/h245/h245.cnf +++ b/epan/dissectors/asn1/h245/h245.cnf @@ -684,7 +684,7 @@ if (h245_pi != NULL) if (gefx) { ti = proto_tree_add_string(tree, hf_h245_debug_dissector_try_string, tvb, offset>>3, 0, gefx->key); PROTO_ITEM_SET_HIDDEN(ti); - dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); + dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset_length_caplen(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); } actx->private_data = gefx; /* subdissector could overwrite it */ #.END @@ -715,7 +715,7 @@ if (h245_pi != NULL) if (gefx) { ti = proto_tree_add_string(tree, hf_h245_debug_dissector_try_string, tvb, offset>>3, 0, gefx->key); PROTO_ITEM_SET_HIDDEN(ti); - dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); + dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset_length_caplen(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); } actx->private_data = gefx; /* subdissector could overwrite it */ #.END diff --git a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c index 7394e237a5..861c3264d3 100644 --- a/epan/dissectors/asn1/kerberos/packet-kerberos-template.c +++ b/epan/dissectors/asn1/kerberos/packet-kerberos-template.c @@ -1792,7 +1792,7 @@ dissect_krb5_AD_WIN2K_PAC_struct(proto_tree *tree, tvbuff_t *tvb, int offset, as proto_tree_add_uint(tr, hf_krb_w2k_pac_offset, tvb, offset, 4, pac_offset); offset += 8; - next_tvb=tvb_new_subset(tvb, pac_offset, pac_size, pac_size); + next_tvb=tvb_new_subset_length_caplen(tvb, pac_offset, pac_size, pac_size); switch(pac_type){ case PAC_LOGON_INFO: dissect_krb5_PAC_LOGON_INFO(tr, next_tvb, 0, actx); diff --git a/epan/dissectors/asn1/ldap/packet-ldap-template.c b/epan/dissectors/asn1/ldap/packet-ldap-template.c index 9298e21377..b78dd6a7a0 100644 --- a/epan/dissectors/asn1/ldap/packet-ldap-template.c +++ b/epan/dissectors/asn1/ldap/packet-ldap-template.c @@ -999,7 +999,7 @@ one_more_pdu: */ length = length_remaining; if (length > msg_len) length = msg_len; - msg_tvb = tvb_new_subset(tvb, offset, length, msg_len); + msg_tvb = tvb_new_subset_length_caplen(tvb, offset, length, msg_len); /* * Now dissect the LDAP message. @@ -1188,7 +1188,7 @@ static void */ length = length_remaining; if (length > sasl_msg_len) length = sasl_msg_len; - sasl_tvb = tvb_new_subset(tvb, offset, length, sasl_msg_len); + sasl_tvb = tvb_new_subset_length_caplen(tvb, offset, length, sasl_msg_len); proto_tree_add_uint(ldap_tree, hf_ldap_sasl_buffer_length, sasl_tvb, 0, 4, sasl_len); @@ -1214,7 +1214,7 @@ static void tmp_length = tvb_reported_length_remaining(sasl_tvb, 4); if ((guint)tmp_length > sasl_len) tmp_length = sasl_len; - gssapi_tvb = tvb_new_subset(sasl_tvb, 4, tmp_length, sasl_len); + gssapi_tvb = tvb_new_subset_length_caplen(sasl_tvb, 4, tmp_length, sasl_len); /* Attempt decryption of the GSSAPI wrapped data if possible */ gssapi_encrypt.gssapi_data_encrypted = FALSE; diff --git a/epan/dissectors/asn1/mpeg-pes/packet-mpeg-pes-template.c b/epan/dissectors/asn1/mpeg-pes/packet-mpeg-pes-template.c index 3fc69bfc74..17c0265664 100644 --- a/epan/dissectors/asn1/mpeg-pes/packet-mpeg-pes-template.c +++ b/epan/dissectors/asn1/mpeg-pes/packet-mpeg-pes-template.c @@ -496,7 +496,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data return TRUE; } - es = tvb_new_subset(tvb, offset / 8, -1, length); + es = tvb_new_subset_length_caplen(tvb, offset / 8, -1, length); if (tvb_get_ntoh24(es, 0) == PES_PREFIX) dissect_mpeg_pes(es, pinfo, tree, NULL); else if (tvb_get_guint8(es, 0) == 0xff) diff --git a/epan/dissectors/asn1/ros/ros-err.cnf b/epan/dissectors/asn1/ros/ros-err.cnf index e9e9bce243..c75dcc8447 100644 --- a/epan/dissectors/asn1/ros/ros-err.cnf +++ b/epan/dissectors/asn1/ros/ros-err.cnf @@ -36,7 +36,7 @@ g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size); if (!err_next_tvb) { /* empty error */ - err_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + err_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((err_handle)?err_handle:data_handle, err_next_tvb, actx->pinfo, tree, actx->rose_ctx); diff --git a/epan/dissectors/asn1/ros/ros-inv.cnf b/epan/dissectors/asn1/ros/ros-inv.cnf index acbcaff2d2..8fcea47d7a 100644 --- a/epan/dissectors/asn1/ros/ros-inv.cnf +++ b/epan/dissectors/asn1/ros/ros-inv.cnf @@ -36,7 +36,7 @@ g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size); if (!arg_next_tvb) { /* empty argument */ - arg_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + arg_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((arg_handle)?arg_handle:data_handle, arg_next_tvb, actx->pinfo, tree, actx->rose_ctx); diff --git a/epan/dissectors/asn1/ros/ros-res.cnf b/epan/dissectors/asn1/ros/ros-res.cnf index 69b09f82a6..fa98dd4b87 100644 --- a/epan/dissectors/asn1/ros/ros-res.cnf +++ b/epan/dissectors/asn1/ros/ros-res.cnf @@ -38,7 +38,7 @@ if (actx->rose_ctx->d.code != -1) { if (!res_next_tvb) { /* empty result */ - res_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + res_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((res_handle)?res_handle:data_handle, res_next_tvb, actx->pinfo, tree, actx->rose_ctx); diff --git a/epan/dissectors/asn1/spnego/packet-spnego-template.c b/epan/dissectors/asn1/spnego/packet-spnego-template.c index 9f4e1986f1..da3564fdda 100644 --- a/epan/dissectors/asn1/spnego/packet-spnego-template.c +++ b/epan/dissectors/asn1/spnego/packet-spnego-template.c @@ -1041,7 +1041,7 @@ dissect_spnego_krb5_cfx_wrap_base(tvbuff_t *tvb, int offset, packet_info *pinfo */ return offset; } - gssapi_encrypt->gssapi_encrypted_tvb = tvb_new_subset( + gssapi_encrypt->gssapi_encrypted_tvb = tvb_new_subset_length_caplen( tvb, offset, len, len); } diff --git a/epan/dissectors/file-btsnoop.c b/epan/dissectors/file-btsnoop.c index 35eba3887d..eafde7750a 100644 --- a/epan/dissectors/file-btsnoop.c +++ b/epan/dissectors/file-btsnoop.c @@ -205,7 +205,7 @@ dissect_btsnoop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data pinfo->pseudo_header->bthci.channel = BTHCI_CHANNEL_ACL; } - next_tvb = tvb_new_subset(tvb, offset, length, length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, length); call_dissector(hci_h1_handle, next_tvb, pinfo, payload_tree); break; case 1002: /* H4 */ @@ -213,7 +213,7 @@ dissect_btsnoop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data pinfo->abs_ts = timestamp; pinfo->p2p_dir = (flags & 0x01) ? P2P_DIR_RECV : P2P_DIR_SENT; - next_tvb = tvb_new_subset(tvb, offset, length, length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, length); call_dissector(hci_h4_handle, next_tvb, pinfo, payload_tree); break; case 2001: /* Linux Monitor */ @@ -223,7 +223,7 @@ dissect_btsnoop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data pinfo->pseudo_header->btmon.opcode = flags & 0xFFFF; pinfo->pseudo_header->btmon.adapter_id = flags >> 16; - next_tvb = tvb_new_subset(tvb, offset, length, length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, length); call_dissector(hci_mon_handle, next_tvb, pinfo, payload_tree); break; diff --git a/epan/dissectors/file-pcap.c b/epan/dissectors/file-pcap.c index a53807c699..6be01491b2 100644 --- a/epan/dissectors/file-pcap.c +++ b/epan/dissectors/file-pcap.c @@ -187,7 +187,7 @@ dissect_pcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ if (pref_dissect_next_layer) { TRY { - call_dissector_with_data(pcap_pktdata_handle, tvb_new_subset(tvb, offset, length, origin_length), pinfo, packet_data_tree, &link_type); + call_dissector_with_data(pcap_pktdata_handle, tvb_new_subset_length_caplen(tvb, offset, length, origin_length), pinfo, packet_data_tree, &link_type); } CATCH_BOUNDS_ERRORS { show_exception(tvb, pinfo, packet_data_tree, EXCEPT_CODE, GET_MESSAGE); diff --git a/epan/dissectors/file-pcapng.c b/epan/dissectors/file-pcapng.c index bc679815c0..7aabb68a03 100644 --- a/epan/dissectors/file-pcapng.c +++ b/epan/dissectors/file-pcapng.c @@ -1015,7 +1015,7 @@ static gint dissect_block(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, interface_description = (struct interface_description *) wmem_array_index(info->interfaces, interface_id); TRY { - call_dissector_with_data(pcap_pktdata_handle, tvb_new_subset(tvb, offset, captured_length, reported_length), + call_dissector_with_data(pcap_pktdata_handle, tvb_new_subset_length_caplen(tvb, offset, captured_length, reported_length), pinfo, packet_data_tree, &interface_description->link_type); } CATCH_BOUNDS_ERRORS { @@ -1216,7 +1216,7 @@ static gint dissect_block(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, interface_description = (struct interface_description *) wmem_array_index(info->interfaces, interface_id); TRY { - call_dissector_with_data(pcap_pktdata_handle, tvb_new_subset(tvb, offset, captured_length, reported_length), + call_dissector_with_data(pcap_pktdata_handle, tvb_new_subset_length_caplen(tvb, offset, captured_length, reported_length), pinfo, packet_data_tree, &interface_description->link_type); } CATCH_BOUNDS_ERRORS { diff --git a/epan/dissectors/packet-9p.c b/epan/dissectors/packet-9p.c index efc73994e0..6b634dde98 100644 --- a/epan/dissectors/packet-9p.c +++ b/epan/dissectors/packet-9p.c @@ -1527,7 +1527,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre len = tvb_reported_length_remaining(tvb, offset); reportedlen = ((gint)u32&0xffff) > len ? len : (gint)u32&0xffff; - next_tvb = tvb_new_subset(tvb, offset, len, reportedlen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, len, reportedlen); call_data_dissector(next_tvb, pinfo, tree); offset += len; @@ -1548,7 +1548,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre offset += 4; len = tvb_reported_length_remaining(tvb, offset); reportedlen = ((gint)u32&0xffff) > len ? len : (gint)u32&0xffff; - next_tvb = tvb_new_subset(tvb, offset, len, reportedlen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, len, reportedlen); call_data_dissector(next_tvb, pinfo, tree); offset += len; diff --git a/epan/dissectors/packet-adb.c b/epan/dissectors/packet-adb.c index c1a85f399f..cf3d526054 100644 --- a/epan/dissectors/packet-adb.c +++ b/epan/dissectors/packet-adb.c @@ -720,7 +720,7 @@ dissect_adb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) } } - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), tvb_captured_length_remaining(tvb, offset)); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), tvb_captured_length_remaining(tvb, offset)); call_dissector_with_data(adb_service_handle, next_tvb, pinfo, tree, &adb_service_data); } else { diff --git a/epan/dissectors/packet-adb_cs.c b/epan/dissectors/packet-adb_cs.c index b5f93ec293..b2f3426574 100644 --- a/epan/dissectors/packet-adb_cs.c +++ b/epan/dissectors/packet-adb_cs.c @@ -175,7 +175,7 @@ dissect_adb_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ adb_service_data.session_key[1] = pinfo->destport; adb_service_data.session_key[2] = pinfo->srcport; - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), tvb_captured_length_remaining(tvb, offset)); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), tvb_captured_length_remaining(tvb, offset)); call_dissector_with_data(adb_service_handle, next_tvb, pinfo, tree, &adb_service_data); return tvb_captured_length(tvb); @@ -341,7 +341,7 @@ dissect_adb_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ adb_service_data.session_key[1] = pinfo->destport; adb_service_data.session_key[2] = pinfo->srcport; - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), tvb_captured_length_remaining(tvb, offset)); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), tvb_captured_length_remaining(tvb, offset)); call_dissector_with_data(adb_service_handle, next_tvb, pinfo, tree, &adb_service_data); offset = tvb_captured_length(tvb); } else { diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c index 928fc420a4..eef1ca0adb 100644 --- a/epan/dissectors/packet-bgp.c +++ b/epan/dissectors/packet-bgp.c @@ -7867,7 +7867,7 @@ dissect_bgp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) length = length_remaining; if (length > bgp_len) length = bgp_len; - next_tvb = tvb_new_subset(tvb, offset, length, bgp_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, bgp_len); /* * Dissect the PDU. diff --git a/epan/dissectors/packet-bluecom.c b/epan/dissectors/packet-bluecom.c index 518c9405a5..4161e2747d 100644 --- a/epan/dissectors/packet-bluecom.c +++ b/epan/dissectors/packet-bluecom.c @@ -417,7 +417,7 @@ dissect_bcp_data(proto_tree *bcp_tree, packet_info *pinfo, tvbuff_t *tvb, if (handle) { /* Generate a new tvb for the rest. */ - next_tvb = tvb_new_subset(tvb, *offset, len, len); + next_tvb = tvb_new_subset_length_caplen(tvb, *offset, len, len); /* Call the sub-dissector. */ call_dissector(handle, next_tvb, pinfo, bcp_tree); diff --git a/epan/dissectors/packet-brdwlk.c b/epan/dissectors/packet-brdwlk.c index b585522063..b5024e5d9b 100644 --- a/epan/dissectors/packet-brdwlk.c +++ b/epan/dissectors/packet-brdwlk.c @@ -312,7 +312,7 @@ dissect_brdwlk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _ } fc_data.ethertype = ETHERTYPE_BRDWALK; - next_tvb = tvb_new_subset(tvb, 2, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, 2, len, reported_len); call_dissector_with_data(fc_dissector_handle, next_tvb, pinfo, tree, &fc_data); return tvb_captured_length(tvb); } diff --git a/epan/dissectors/packet-btatt.c b/epan/dissectors/packet-btatt.c index d366f0b5fb..2cc77e747a 100644 --- a/epan/dissectors/packet-btatt.c +++ b/epan/dissectors/packet-btatt.c @@ -4054,7 +4054,7 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * const gint **hfs; bluetooth_data_t *bluetooth_data = NULL; - tvb = tvb_new_subset(old_tvb, old_offset, length, length); + tvb = tvb_new_subset_length_caplen(old_tvb, old_offset, length, length); DISSECTOR_ASSERT(att_data); @@ -4470,13 +4470,13 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * sub_tree = proto_item_add_subtree(sub_item, ett_btatt_list); if (characteristic_dissector) - call_dissector_with_data(characteristic_dissector, tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset) / 2, tvb_reported_length_remaining(tvb, offset) / 2), pinfo, sub_tree, att_data); + call_dissector_with_data(characteristic_dissector, tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset) / 2, tvb_reported_length_remaining(tvb, offset) / 2), pinfo, sub_tree, att_data); sub_item = proto_tree_add_item(tree, hf_btatt_valid_range_upper_inclusive_value, tvb, offset + tvb_reported_length_remaining(tvb, offset) / 2, tvb_reported_length_remaining(tvb, offset) / 2, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_btatt_list); if (characteristic_dissector) - call_dissector_with_data(characteristic_dissector, tvb_new_subset(tvb, offset + tvb_reported_length_remaining(tvb, offset) / 2, tvb_reported_length_remaining(tvb, offset) / 2, tvb_reported_length_remaining(tvb, offset) / 2), pinfo, sub_tree, att_data); + call_dissector_with_data(characteristic_dissector, tvb_new_subset_length_caplen(tvb, offset + tvb_reported_length_remaining(tvb, offset) / 2, tvb_reported_length_remaining(tvb, offset) / 2, tvb_reported_length_remaining(tvb, offset) / 2), pinfo, sub_tree, att_data); offset += tvb_reported_length_remaining(tvb, offset); } @@ -4556,7 +4556,7 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * proto_tree_add_item(tree, hf_btatt_value_trigger_setting_analog, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; } else if (value == 4) { - call_dissector_with_data(find_dissector("btgatt.uuid0x2a56"), tvb_new_subset(tvb, offset, 1, 1), pinfo, tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a56"), tvb_new_subset_length_caplen(tvb, offset, 1, 1), pinfo, tree, att_data); offset += 1; } else if (value == 5 || value == 6) { proto_tree_add_item(tree, hf_btatt_value_trigger_setting_analog_one, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -6282,10 +6282,10 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * if (bluetooth_gatt_has_no_parameter(att_data->opcode)) break; - call_dissector_with_data(find_dissector("btgatt.uuid0x2a56"), tvb_new_subset(tvb, offset, 1, 1), pinfo, tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a56"), tvb_new_subset_length_caplen(tvb, offset, 1, 1), pinfo, tree, att_data); offset += 1; - call_dissector_with_data(find_dissector("btgatt.uuid0x2a58"), tvb_new_subset(tvb, offset, 2, 2), pinfo, tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a58"), tvb_new_subset_length_caplen(tvb, offset, 2, 2), pinfo, tree, att_data); offset += 2; break; @@ -6382,7 +6382,7 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * sub_item = proto_tree_add_item(tree, hf_btatt_plx_spot_check_measurement_timestamp, tvb, offset, 7, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_btatt_value); - call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset(tvb, offset, 7, 7), pinfo, sub_tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset_length_caplen(tvb, offset, 7, 7), pinfo, sub_tree, att_data); offset += 7; } @@ -8950,7 +8950,7 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * sub_item = proto_tree_add_item(tree, hf_btatt_ots_object_first_created, tvb, offset, 7, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_btatt_value); - call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset(tvb, offset, 7, 7), pinfo, sub_tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset_length_caplen(tvb, offset, 7, 7), pinfo, sub_tree, att_data); offset += 7; break; @@ -8969,7 +8969,7 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * sub_item = proto_tree_add_item(tree, hf_btatt_ots_object_last_modified, tvb, offset, 7, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_btatt_value); - call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset(tvb, offset, 7, 7), pinfo, sub_tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset_length_caplen(tvb, offset, 7, 7), pinfo, sub_tree, att_data); offset += 7; break; @@ -9176,10 +9176,10 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info * break; case 0x06: /* Created Between */ case 0x07: /* Modified Between */ - call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset(tvb, offset, 7, 7), pinfo, tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset_length_caplen(tvb, offset, 7, 7), pinfo, tree, att_data); offset += 7; - call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset(tvb, offset, 7, 7), pinfo, tree, att_data); + call_dissector_with_data(find_dissector("btgatt.uuid0x2a08"), tvb_new_subset_length_caplen(tvb, offset, 7, 7), pinfo, tree, att_data); offset += 7; break; diff --git a/epan/dissectors/packet-bthci_acl.c b/epan/dissectors/packet-bthci_acl.c index a294903411..341b994425 100644 --- a/epan/dissectors/packet-bthci_acl.c +++ b/epan/dissectors/packet-bthci_acl.c @@ -430,7 +430,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat length = tvb_captured_length_remaining(tvb, offset); } - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); call_dissector_with_data(btl2cap_handle, next_tvb, pinfo, tree, acl_data); } else if (fragmented && acl_reassembly) { multi_fragment_pdu_t *mfp = NULL; diff --git a/epan/dissectors/packet-btl2cap.c b/epan/dissectors/packet-btl2cap.c index 1a7f8db062..30134cef3a 100644 --- a/epan/dissectors/packet-btl2cap.c +++ b/epan/dissectors/packet-btl2cap.c @@ -1919,7 +1919,7 @@ dissect_b_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, { tvbuff_t *next_tvb; - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); col_append_str(pinfo->cinfo, COL_INFO, "Connection oriented channel"); @@ -2248,7 +2248,7 @@ dissect_i_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } /*pass up to higher layer if we have a complete packet*/ if (segment == 0x00) { - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset) - 2, length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset) - 2, length); } if (next_tvb) { if (psm) { @@ -2608,7 +2608,7 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) proto_tree_add_item(btl2cap_tree, hf_btl2cap_psm, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); /* call next dissector */ if (!dissector_try_uint_new(l2cap_psm_dissector_table, (guint32) psm, next_tvb, pinfo, tree, TRUE, l2cap_data)) { @@ -2662,11 +2662,11 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) offset += 2; proto_tree_add_item(btl2cap_tree, hf_btl2cap_fcs, tvb, tvb_reported_length(tvb) - 2, 2, ENC_LITTLE_ENDIAN); - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset)-2, length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset)-2, length); } } else { - next_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), length); } /* call next dissector */ if (next_tvb && !dissector_try_uint_new(l2cap_cid_dissector_table, (guint32) cid, diff --git a/epan/dissectors/packet-bvlc.c b/epan/dissectors/packet-bvlc.c index 38dbe85c42..e1a4fea468 100644 --- a/epan/dissectors/packet-bvlc.c +++ b/epan/dissectors/packet-bvlc.c @@ -286,7 +286,7 @@ dissect_bvlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ * BACnet NPDU */ npdu_length = packet_length - bvlc_length; - next_tvb = tvb_new_subset(tvb,bvlc_length,-1,npdu_length); + next_tvb = tvb_new_subset_length_caplen(tvb,bvlc_length,-1,npdu_length); /* Code from Guy Harris */ if (!dissector_try_uint(bvlc_dissector_table, bvlc_function, next_tvb, pinfo, tree)) { diff --git a/epan/dissectors/packet-c15ch.c b/epan/dissectors/packet-c15ch.c index 2353c6f40a..cc5afedcf5 100644 --- a/epan/dissectors/packet-c15ch.c +++ b/epan/dissectors/packet-c15ch.c @@ -4253,7 +4253,7 @@ static int dissect_c15ch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo proto_tree_add_item(c15ch_tree, hf_c15ch_realtime, tvb, 32, 4, ENC_BIG_ENDIAN); } - next_tvb = tvb_new_subset(tvb, HEADER_SZ, -1, payload_length); + next_tvb = tvb_new_subset_length_caplen(tvb, HEADER_SZ, -1, payload_length); /* call dissector to dissect the rest of the packet, based on msg_type */ retv = HEADER_SZ + dissector_try_uint(c15ch_dissector_table, msg_type, next_tvb, pinfo, tree); return retv; @@ -4621,7 +4621,7 @@ static int dissect_c15ch_encap_isup(tvbuff_t *tvb, packet_info *pinfo, proto_tre tvb, 1, 4, ENC_BIG_ENDIAN); /*length of ISUP portion == expected length == 268 */ - next_tvb = tvb_new_subset(tvb, 5, 268, 268); + next_tvb = tvb_new_subset_length_caplen(tvb, 5, 268, 268); call_dissector(general_isup_handle, next_tvb, pinfo, tree); } @@ -4696,7 +4696,7 @@ static int dissect_c15ch_isup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre tvb, 41, 8, ENC_NA); /*length of ISUP portion == expected length == 271 */ - next_tvb = tvb_new_subset(tvb, 49, 271, 271); + next_tvb = tvb_new_subset_length_caplen(tvb, 49, 271, 271); call_dissector(general_isup_handle, next_tvb, pinfo, tree); } @@ -5470,7 +5470,7 @@ static int dissect_c15ch_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre tvb, 9, 4, ENC_BIG_ENDIAN); if (q931_msg_len && bytes_to_skip) { - next_tvb = tvb_new_subset(tvb, 13 + bytes_to_skip, q931_msg_len - bytes_to_skip, q931_msg_len - bytes_to_skip); + next_tvb = tvb_new_subset_length_caplen(tvb, 13 + bytes_to_skip, q931_msg_len - bytes_to_skip, q931_msg_len - bytes_to_skip); call_dissector(general_q931_handle, next_tvb, pinfo, tree); } } @@ -5658,7 +5658,7 @@ static int dissect_c15ch_sccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre tvb, 298, 4, ENC_BIG_ENDIAN); /* skip bytes to get to SCCP message type */ - next_tvb = tvb_new_subset(tvb, 23 + 2, + next_tvb = tvb_new_subset_length_caplen(tvb, 23 + 2, 275 - 2, 275 - 2); /* sccp dissector call */ @@ -5978,7 +5978,7 @@ static int dissect_c15ch_inc_gwe(tvbuff_t *tvb, packet_info *pinfo, proto_tree * proto_tree_add_item(c15ch_inc_gwe_tree, hf_c15ch_inc_gwe_datatype, tvb, 10, 1, ENC_BIG_ENDIAN); } - next_tvb = tvb_new_subset(tvb, 11, -1, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, 11, -1, -1); /*third level dissection*/ retv = 11 + dissector_try_uint(c15ch_inc_gwe_dissector_table, type_num, next_tvb, pinfo, tree); return retv; @@ -6641,7 +6641,7 @@ static int dissect_c15ch_out_gwe(tvbuff_t *tvb, packet_info *pinfo, proto_tree * proto_tree_add_item(c15ch_out_gwe_tree, hf_c15ch_out_gwe_gwe_data_type, tvb, 14, 1, ENC_BIG_ENDIAN); } - next_tvb = tvb_new_subset(tvb, 15, -1, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, 15, -1, -1); dissector_try_uint(c15ch_out_gwe_dissector_table, data_type, next_tvb, pinfo, tree); return tvb_reported_length(tvb); @@ -7208,7 +7208,7 @@ static int dissect_c15ch_tone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre proto_tree_add_item(c15ch_tone_tree, hf_c15ch_tone_msg_type, tvb, 0, 1, ENC_BIG_ENDIAN); } - next_tvb = tvb_new_subset(tvb, 1, -1, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, 1, -1, -1); retv = 1 + dissector_try_uint(c15ch_tone_dissector_table, msg_type, next_tvb, pinfo, tree); return retv; } diff --git a/epan/dissectors/packet-cmp.c b/epan/dissectors/packet-cmp.c index 800cdea1e9..2c2bd1ccab 100644 --- a/epan/dissectors/packet-cmp.c +++ b/epan/dissectors/packet-cmp.c @@ -1558,7 +1558,7 @@ static int dissect_cmp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa switch(pdu_type){ case CMP_TYPE_PKIMSG: - next_tvb = tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); dissect_cmp_pdu(next_tvb, tree, &asn1_ctx); offset += tvb_reported_length_remaining(tvb, offset); break; @@ -1586,12 +1586,12 @@ static int dissect_cmp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa proto_tree_add_time(tcptrans_tree, hf_cmp_tcptrans_ttcb, tvb, offset, 4, &ts); offset += 4; - next_tvb = tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); dissect_cmp_pdu(next_tvb, tree, &asn1_ctx); offset += tvb_reported_length_remaining(tvb, offset); break; case CMP_TYPE_FINALMSGREP: - next_tvb = tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), pdu_len); dissect_cmp_pdu(next_tvb, tree, &asn1_ctx); offset += tvb_reported_length_remaining(tvb, offset); break; diff --git a/epan/dissectors/packet-componentstatus.c b/epan/dissectors/packet-componentstatus.c index 1a4040bebb..2490f53de6 100644 --- a/epan/dissectors/packet-componentstatus.c +++ b/epan/dissectors/packet-componentstatus.c @@ -174,7 +174,7 @@ dissect_componentstatusprotocol_componentstatusreport_message(tvbuff_t *message_ while(tvb_reported_length_remaining(message_tvb, offset) >= COMPONENTASSOCIATION_LENGTH) { association_tree = proto_tree_add_subtree_format(message_tree, message_tvb, offset, COMPONENTASSOCIATION_LENGTH, ett_association, NULL, "Association #%d", i++); - association_tvb = tvb_new_subset(message_tvb, offset, + association_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(COMPONENTASSOCIATION_LENGTH, tvb_reported_length_remaining(message_tvb, offset)), COMPONENTASSOCIATION_LENGTH); diff --git a/epan/dissectors/packet-corosync-totemnet.c b/epan/dissectors/packet-corosync-totemnet.c index afaf8f6a68..01c1e274af 100644 --- a/epan/dissectors/packet-corosync-totemnet.c +++ b/epan/dissectors/packet-corosync-totemnet.c @@ -347,7 +347,7 @@ dissect_corosynec_totemnet_with_decryption(tvbuff_t *tvb, dissect_corosync_totemnet_security_header(decrypted_tvb, pinfo, parent_tree, check_crypt_type, key_for_trial); - next_tvb = tvb_new_subset(decrypted_tvb, + next_tvb = tvb_new_subset_length_caplen(decrypted_tvb, SHA1_DIGEST_LEN + SALT_SIZE, io_len - (SHA1_DIGEST_LEN + SALT_SIZE), io_len - (SHA1_DIGEST_LEN + SALT_SIZE)); diff --git a/epan/dissectors/packet-couchbase.c b/epan/dissectors/packet-couchbase.c index c93ea0f3d6..6fb48bf43f 100644 --- a/epan/dissectors/packet-couchbase.c +++ b/epan/dissectors/packet-couchbase.c @@ -1217,7 +1217,7 @@ dissect_multipath_lookup_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree_add_item(multipath_tree, hf_value, tvb, offset, result_len, ENC_ASCII | ENC_NA); if (result_len > 0) { - json_tvb = tvb_new_subset(tvb, offset, result_len, result_len); + json_tvb = tvb_new_subset_length_caplen(tvb, offset, result_len, result_len); call_dissector(json_handle, json_tvb, pinfo, multipath_tree); } offset += result_len; @@ -1267,7 +1267,7 @@ dissect_multipath_mutation_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree_add_item(multipath_tree, hf_value, tvb, offset, result_len, ENC_ASCII | ENC_NA); if (result_len > 0) { - json_tvb = tvb_new_subset(tvb, offset, result_len, result_len); + json_tvb = tvb_new_subset_length_caplen(tvb, offset, result_len, result_len); call_dissector(json_handle, json_tvb, pinfo, multipath_tree); } offset += result_len; @@ -1473,7 +1473,7 @@ dissect_value(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } else if (!request && has_json_value(opcode)) { tvbuff_t *json_tvb; ti = proto_tree_add_item(tree, hf_value, tvb, offset, value_len, ENC_ASCII | ENC_NA); - json_tvb = tvb_new_subset(tvb, offset, value_len, value_len); + json_tvb = tvb_new_subset_length_caplen(tvb, offset, value_len, value_len); call_dissector(json_handle, json_tvb, pinfo, tree); } else if (opcode == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP || @@ -1683,7 +1683,7 @@ dissect_couchbase(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat ENC_ASCII | ENC_NA); if (status == PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET) { tvbuff_t *json_tvb; - json_tvb = tvb_new_subset(tvb, offset, bodylen, bodylen); + json_tvb = tvb_new_subset_length_caplen(tvb, offset, bodylen, bodylen); call_dissector(json_handle, json_tvb, pinfo, couchbase_tree); } else if (opcode == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP) { diff --git a/epan/dissectors/packet-cp2179.c b/epan/dissectors/packet-cp2179.c index d3d5ae8197..c7377ac1cc 100644 --- a/epan/dissectors/packet-cp2179.c +++ b/epan/dissectors/packet-cp2179.c @@ -970,7 +970,7 @@ dissect_cp2179(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) cp2179_tvb = clean_telnet_iac(pinfo, tvb, 0, length); } else{ - /* cp2179_tvb = tvb_new_subset( tvb, 0, length, length); */ + /* cp2179_tvb = tvb_new_subset_length_caplen( tvb, 0, length, length); */ cp2179_tvb = tvb_new_subset_length( tvb, 0, length); } diff --git a/epan/dissectors/packet-cpfi.c b/epan/dissectors/packet-cpfi.c index 671febe62d..b4587284d0 100644 --- a/epan/dissectors/packet-cpfi.c +++ b/epan/dissectors/packet-cpfi.c @@ -368,7 +368,7 @@ dissect_cpfi(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void * header_tvb = tvb_new_subset_length(message_tvb, 0, 8); dissect_cpfi_header(header_tvb, pinfo, cpfi_tree); - body_tvb = tvb_new_subset(message_tvb, 8, body_length, reported_body_length); + body_tvb = tvb_new_subset_length_caplen(message_tvb, 8, body_length, reported_body_length); fc_data.ethertype = 0; call_dissector_with_data(fc_handle, body_tvb, pinfo, tree, &fc_data); @@ -377,7 +377,7 @@ dissect_cpfi(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void * col_prepend_fstr(pinfo->cinfo, COL_INFO, direction_and_port_string, left, arrow, right); /* Do the footer */ - footer_tvb = tvb_new_subset(message_tvb, 8+body_length, length, 8); + footer_tvb = tvb_new_subset_length_caplen(message_tvb, 8+body_length, length, 8); dissect_cpfi_footer(footer_tvb, cpfi_tree); return(tvb_reported_length(message_tvb)); diff --git a/epan/dissectors/packet-dcerpc-dnsserver.c b/epan/dissectors/packet-dcerpc-dnsserver.c index 2ac28e9d38..5c34cef759 100644 --- a/epan/dissectors/packet-dcerpc-dnsserver.c +++ b/epan/dissectors/packet-dcerpc-dnsserver.c @@ -2917,7 +2917,7 @@ dnsserver_dissect_element_DnssrvEnumRecords2_record_buffer_(tvbuff_t *tvb _U_, i guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_dnsserver_DnssrvEnumRecords2_record_buffer_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); dnsserver_dissect_element_DnssrvEnumRecords2_record_buffer__(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; diff --git a/epan/dissectors/packet-dcerpc-eventlog.c b/epan/dissectors/packet-dcerpc-eventlog.c index 331c624fba..8449718460 100644 --- a/epan/dissectors/packet-dcerpc-eventlog.c +++ b/epan/dissectors/packet-dcerpc-eventlog.c @@ -287,7 +287,7 @@ eventlog_dissect_element_ReadEventLogW_data_(tvbuff_t *tvb, int offset, packet_i * NDR encoded at all and there are byte offsets into this buffer * encoded therein. */ - record_tvb=tvb_new_subset(tvb, offset, MIN((gint)len, tvb_captured_length_remaining(tvb, offset)), len); + record_tvb=tvb_new_subset_length_caplen(tvb, offset, MIN((gint)len, tvb_captured_length_remaining(tvb, offset)), len); eventlog_dissect_struct_Record(record_tvb, 0, pinfo, tree, di, drep, hf_eventlog_Record, 0); offset+=len; return offset; @@ -312,7 +312,7 @@ eventlog_dissect_element_Record_sid_offset(tvbuff_t *tvb, int offset, packet_inf /* this blob contains an NT SID. * tvb starts at the beginning of the record. */ - sid_tvb=tvb_new_subset(tvb, sid_offset, MIN((gint)sid_length, tvb_captured_length_remaining(tvb, offset)), sid_length); + sid_tvb=tvb_new_subset_length_caplen(tvb, sid_offset, MIN((gint)sid_length, tvb_captured_length_remaining(tvb, offset)), sid_length); dissect_nt_sid(sid_tvb, 0, tree, "SID", NULL, -1); } return offset; diff --git a/epan/dissectors/packet-dcerpc-frsrpc.c b/epan/dissectors/packet-dcerpc-frsrpc.c index f2b0716854..f019e7c207 100644 --- a/epan/dissectors/packet-dcerpc-frsrpc.c +++ b/epan/dissectors/packet-dcerpc-frsrpc.c @@ -739,7 +739,7 @@ frsrpc_dissect_element_CommPktChunkGuidName_guid(tvbuff_t *tvb _U_, int offset _ guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkGuidName_guid_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkGuidName_guid_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -767,7 +767,7 @@ frsrpc_dissect_element_CommPktChunkGuidName_name(tvbuff_t *tvb _U_, int offset _ guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkGuidName_name_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkGuidName_name_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2150,7 +2150,7 @@ frsrpc_dissect_element_CommPktChunkData_join_guid(tvbuff_t *tvb _U_, int offset guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_join_guid_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_join_guid_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2186,7 +2186,7 @@ frsrpc_dissect_element_CommPktChunkData_vvector(tvbuff_t *tvb _U_, int offset _U guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_vvector_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_vvector_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2214,7 +2214,7 @@ frsrpc_dissect_element_CommPktChunkData_join_time(tvbuff_t *tvb _U_, int offset guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_join_time_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_join_time_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2242,7 +2242,7 @@ frsrpc_dissect_element_CommPktChunkData_replica_version_guid(tvbuff_t *tvb _U_, guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_replica_version_guid_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_replica_version_guid_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2310,7 +2310,7 @@ frsrpc_dissect_element_CommPktChunkData_gvsn(tvbuff_t *tvb _U_, int offset _U_, guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_gvsn_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_gvsn_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2338,7 +2338,7 @@ frsrpc_dissect_element_CommPktChunkData_co_guid(tvbuff_t *tvb _U_, int offset _U guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_co_guid_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_co_guid_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2374,7 +2374,7 @@ frsrpc_dissect_element_CommPktChunkData_remote_co(tvbuff_t *tvb _U_, int offset guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_remote_co_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_remote_co_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2402,7 +2402,7 @@ frsrpc_dissect_element_CommPktChunkData_co_ext_win2k(tvbuff_t *tvb _U_, int offs guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunkData_co_ext_win2k_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunkData_co_ext_win2k_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -2575,7 +2575,7 @@ frsrpc_dissect_element_CommPktChunk_data(tvbuff_t *tvb _U_, int offset _U_, pack guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_CommPktChunk_data_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_CommPktChunk_data_(subtvb, 0, pinfo, tree, di, drep, type); offset += (int)size; di->call_data->flags = saved_flags; @@ -2725,7 +2725,7 @@ frsrpc_dissect_element_FrsSendCommPktReq_ctr_(tvbuff_t *tvb _U_, int offset _U_, guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_FrsSendCommPktReq_ctr_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_FrsSendCommPktReq_ctr__(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -3160,7 +3160,7 @@ frsrpc_dissect_element_FrsStartPromotionParent_connection_guid_(tvbuff_t *tvb _U guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_FrsStartPromotionParent_connection_guid_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_FrsStartPromotionParent_connection_guid__(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -3196,7 +3196,7 @@ frsrpc_dissect_element_FrsStartPromotionParent_partner_guid_(tvbuff_t *tvb _U_, guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_FrsStartPromotionParent_partner_guid_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_FrsStartPromotionParent_partner_guid__(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; @@ -3232,7 +3232,7 @@ frsrpc_dissect_element_FrsStartPromotionParent_parent_guid_(tvbuff_t *tvb _U_, i guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, hf_frsrpc_frsrpc_FrsStartPromotionParent_parent_guid_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); frsrpc_dissect_element_FrsStartPromotionParent_parent_guid__(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; diff --git a/epan/dissectors/packet-dcerpc-krb5rpc.c b/epan/dissectors/packet-dcerpc-krb5rpc.c index f0f5eac91d..9ee6df0639 100644 --- a/epan/dissectors/packet-dcerpc-krb5rpc.c +++ b/epan/dissectors/packet-dcerpc-krb5rpc.c @@ -85,7 +85,7 @@ krb5rpc_dissect_sendto_kdc_rqst (tvbuff_t * tvb, int offset, subtree = proto_item_add_subtree (item, ett_krb5rpc_krb5); remain = tvb_captured_length_remaining(tvb, offset); - krb5_tvb = tvb_new_subset (tvb, offset, remain, remain); + krb5_tvb = tvb_new_subset_length_caplen (tvb, offset, remain, remain); offset = dissect_kerberos_main (krb5_tvb, pinfo, subtree, TRUE, NULL); @@ -130,7 +130,7 @@ krb5rpc_dissect_sendto_kdc_resp (tvbuff_t * tvb, int offset, item = proto_tree_add_item (tree, hf_krb5rpc_krb5, tvb, offset, -1, ENC_NA); subtree = proto_item_add_subtree (item, ett_krb5rpc_krb5); remain = tvb_captured_length_remaining(tvb, offset); - krb5_tvb = tvb_new_subset (tvb, offset, remain, remain); + krb5_tvb = tvb_new_subset_length_caplen (tvb, offset, remain, remain); offset = dissect_kerberos_main (krb5_tvb, pinfo, subtree, TRUE, NULL); offset += 16; /* no idea what this is, probably just extended encrypted text. */ diff --git a/epan/dissectors/packet-dcerpc-lsa.c b/epan/dissectors/packet-dcerpc-lsa.c index 936a13a2e9..c233a2bade 100644 --- a/epan/dissectors/packet-dcerpc-lsa.c +++ b/epan/dissectors/packet-dcerpc-lsa.c @@ -1572,7 +1572,7 @@ lsarpc_dissect_element_lsa_DomainInfoEfs_efs_blob_(tvbuff_t *tvb _U_, int offset if (len > tvb_captured_length_remaining(tvb, offset)) { len = tvb_captured_length_remaining(tvb, offset); } - next_tvb = tvb_new_subset(tvb, offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, len, reported_len); efsblob_handle = find_dissector("efsblob"); if (efsblob_handle) { call_dissector(efsblob_handle, next_tvb, pinfo, tree); diff --git a/epan/dissectors/packet-dcerpc-mapi.c b/epan/dissectors/packet-dcerpc-mapi.c index 5349e56493..4806da9ae9 100644 --- a/epan/dissectors/packet-dcerpc-mapi.c +++ b/epan/dissectors/packet-dcerpc-mapi.c @@ -4278,7 +4278,7 @@ mapi_dissect_element_EcDoRpc_response__(tvbuff_t *tvb _U_, int offset _U_, packe guint16 length; tvbuff_t *subtvb; length = tvb_get_letohs(tvb, offset); - subtvb = tvb_new_subset(tvb, offset, length, length); + subtvb = tvb_new_subset_length_caplen(tvb, offset, length, length); offset += 2; while (offset < length) { offset = mapi_dissect_struct_EcDoRpc_MAPI_REPL(subtvb, offset, pinfo, tree, di, drep, hf_mapi_mapi_response_mapi_repl, length - offset); @@ -9118,7 +9118,7 @@ mapi_dissect_element_OpenMessage_recipients_recipients_headers(tvbuff_t *tvb _U_ guint32 saved_flags = di->call_data->flags; offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, di, drep, hf_mapi_OpenMessage_recipients_recipients_headers_, &size); di->call_data->flags &= ~DCERPC_IS_NDR64; - subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1); + subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1); mapi_dissect_element_OpenMessage_recipients_recipients_headers_(subtvb, 0, pinfo, tree, di, drep); offset += (int)size; di->call_data->flags = saved_flags; diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c index 206a6410f6..4f04a3c8bb 100644 --- a/epan/dissectors/packet-dcerpc.c +++ b/epan/dissectors/packet-dcerpc.c @@ -1532,7 +1532,7 @@ dissect_dcerpc_guid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d if (length > reported_length) length = reported_length; - stub_tvb = tvb_new_subset(tvb, 0, length, reported_length); + stub_tvb = tvb_new_subset_length_caplen(tvb, 0, length, reported_length); auth_pad_len = dissector_data->auth_info->auth_pad_len; auth_pad_offset = reported_length; } else { @@ -1604,7 +1604,7 @@ dissect_dcerpc_guid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d length, plurality(length, "", "s")); } - payload_tvb = tvb_new_subset(stub_tvb, 0, length, length); + payload_tvb = tvb_new_subset_length_caplen(stub_tvb, 0, length, length); offset = sub_dissect(payload_tvb, 0, pinfo, sub_tree, dissector_data->info, dissector_data->drep); @@ -3768,7 +3768,7 @@ dissect_dcerpc_cn_auth(tvbuff_t *tvb, int stub_offset, packet_info *pinfo, /* * Dissect the authentication data. */ - auth_info->auth_tvb = tvb_new_subset(tvb, offset, + auth_info->auth_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(hdr->auth_len,tvb_reported_length_remaining(tvb, offset)), hdr->auth_len); @@ -4215,7 +4215,7 @@ dissect_dcerpc_cn_stub(tvbuff_t *tvb, int offset, packet_info *pinfo, reported_length -= auth_info->auth_size; if (length > reported_length) length = reported_length; - payload_tvb = tvb_new_subset(tvb, offset, length, reported_length); + payload_tvb = tvb_new_subset_length_caplen(tvb, offset, length, reported_length); /* Decrypt the PDU if it is encrypted */ @@ -5434,7 +5434,7 @@ dissect_dcerpc_cn(tvbuff_t *tvb, int offset, packet_info *pinfo, * offset otherwise. */ subtvb_len = MIN(hdr.frag_len, tvb_reported_length(tvb)); - fragment_tvb = tvb_new_subset(tvb, start_offset, + fragment_tvb = tvb_new_subset_length_caplen(tvb, start_offset, subtvb_len /* length */, hdr.frag_len /* reported_length */); @@ -5913,7 +5913,7 @@ dissect_dcerpc_dg_stub(tvbuff_t *tvb, int offset, packet_info *pinfo, * XXX - authentication info? */ pinfo->fragmented = (hdr->flags1 & PFCL1_FRAG); - next_tvb = tvb_new_subset(tvb, offset, length, + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, reported_length); dcerpc_try_handoff(pinfo, tree, dcerpc_tree, next_tvb, TRUE, hdr->drep, di, NULL); } else { diff --git a/epan/dissectors/packet-dcp-etsi.c b/epan/dissectors/packet-dcp-etsi.c index 7170a9b450..2f644f4e9e 100644 --- a/epan/dissectors/packet-dcp-etsi.c +++ b/epan/dissectors/packet-dcp-etsi.c @@ -570,7 +570,7 @@ dissect_af (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _ pt = tvb_get_guint8 (tvb, offset); proto_tree_add_item (af_tree, hf_edcp_pt, tvb, offset, 1, ENC_ASCII|ENC_NA); offset += 1; - next_tvb = tvb_new_subset (tvb, offset, payload_len, payload_len); + next_tvb = tvb_new_subset_length_caplen (tvb, offset, payload_len, payload_len); offset += payload_len; ci = proto_tree_add_item (af_tree, hf_edcp_crc, tvb, offset, 2, ENC_BIG_ENDIAN); if (ver & 0x80) { /* crc valid */ @@ -621,7 +621,7 @@ dissect_tpl(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _ offset, 8+bytes, NULL, "%s (%u bits)", tag, bits); - next_tvb = tvb_new_subset (tvb, offset+8, bytes, bytes); + next_tvb = tvb_new_subset_length_caplen (tvb, offset+8, bytes, bytes); dissector_try_string(tpl_dissector_table, tag, next_tvb, pinfo, tree, NULL); offset += (8+bytes); diff --git a/epan/dissectors/packet-dlsw.c b/epan/dissectors/packet-dlsw.c index ff68a08843..4e7106ccab 100644 --- a/epan/dissectors/packet-dlsw.c +++ b/epan/dissectors/packet-dlsw.c @@ -394,7 +394,7 @@ dissect_dlsw_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data switch (mtype) { case CAP_EXCHANGE: - dissect_dlsw_capex(tvb_new_subset(tvb, hlen, mlen, -1), pinfo, dlsw_data_tree, ti2); + dissect_dlsw_capex(tvb_new_subset_length_caplen(tvb, hlen, mlen, -1), pinfo, dlsw_data_tree, ti2); break; case IFCM: case INFOFRAME: diff --git a/epan/dissectors/packet-dof.c b/epan/dissectors/packet-dof.c index 551984ff45..4c78d44bec 100644 --- a/epan/dissectors/packet-dof.c +++ b/epan/dissectors/packet-dof.c @@ -2522,7 +2522,7 @@ static int dissect_2008_16_security_2(tvbuff_t *tvb, packet_info *pinfo, proto_t { proto_item *ti = proto_tree_add_item(tree, hf_security_2_permission, tvb, offset, -1, ENC_NA); proto_tree *subtree = proto_item_add_subtree(ti, ett_security_2_permission); - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, -1); gint len = dissect_2008_16_security_1(next_tvb, pinfo, subtree, NULL); proto_item_set_len(ti, len); offset += len; @@ -2564,7 +2564,7 @@ static int dissect_2008_16_security_3_1(tvbuff_t *tvb, packet_info *pinfo, proto /* Security Node Identifier */ { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_tree *subtree; ti = proto_tree_add_item(tree, hf_security_3_1_security_node_identifier, tvb, offset, 0, ENC_NA); subtree = proto_item_add_subtree(ti, ett_security_3_1_security_node_identifier); @@ -2641,7 +2641,7 @@ static int dissect_2008_16_security_4(tvbuff_t *tvb, packet_info *pinfo, proto_t { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; dof_2008_16_security_3_1 return_3_1; @@ -2659,7 +2659,7 @@ static int dissect_2008_16_security_4(tvbuff_t *tvb, packet_info *pinfo, proto_t } { - tvbuff_t *start = tvb_new_subset(tvb, offset, (flag & 0x0F) + 1, (flag & 0x0F) + 1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, (flag & 0x0F) + 1, (flag & 0x0F) + 1); if (return_data) return_data->nonce = start; @@ -2669,7 +2669,7 @@ static int dissect_2008_16_security_4(tvbuff_t *tvb, packet_info *pinfo, proto_t { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; @@ -2717,7 +2717,7 @@ static int dissect_2008_16_security_6_1(tvbuff_t *tvb, packet_info *pinfo, proto /* Desired Security Mode */ { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; @@ -2741,7 +2741,7 @@ static int dissect_2008_16_security_6_1(tvbuff_t *tvb, packet_info *pinfo, proto { int block_length; dof_2008_16_security_4 output; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; @@ -2774,7 +2774,7 @@ static int dissect_2008_16_security_6_2(tvbuff_t *tvb, packet_info *pinfo, proto { int block_length; dof_2008_16_security_4 output; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; @@ -2808,7 +2808,7 @@ static int dissect_2008_16_security_6_3(tvbuff_t *tvb, packet_info *pinfo, proto /* Session Security Scope */ { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; @@ -2822,7 +2822,7 @@ static int dissect_2008_16_security_6_3(tvbuff_t *tvb, packet_info *pinfo, proto /* Initiator Validation */ { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; @@ -2836,7 +2836,7 @@ static int dissect_2008_16_security_6_3(tvbuff_t *tvb, packet_info *pinfo, proto /* Responder Validation */ { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_item *ti; proto_tree *subtree; @@ -2982,7 +2982,7 @@ static int dissect_2008_16_security_11(tvbuff_t *tvb, packet_info *pinfo, proto_ { proto_item *ti = proto_tree_add_item(tree, hf_security_11_permission_security_scope, tvb, offset, -1, ENC_NA); proto_tree *subtree = proto_item_add_subtree(ti, ett_security_11_permission_security_scope); - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, -1); gint len; len = dissect_2008_16_security_12(next_tvb, pinfo, subtree, NULL); proto_item_set_len(ti, len); @@ -3122,7 +3122,7 @@ static gint dissect_2009_11_type_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree do { - tvbuff_t *packet = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *packet = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_tree *attribute_tree; gint attribute_length; @@ -3194,7 +3194,7 @@ static int dissect_2009_11_type_5(tvbuff_t *tvb, packet_info *pinfo, proto_tree case 0: case 2: { - tvbuff_t *packet = tvb_new_subset(tvb, offset, attribute_length_byte, attribute_length_byte); + tvbuff_t *packet = tvb_new_subset_length_caplen(tvb, offset, attribute_length_byte, attribute_length_byte); proto_tree *attribute_tree; ti = proto_tree_add_item(tree, hf_oid_attribute_oid, tvb, offset, -1, ENC_NA); @@ -5672,7 +5672,7 @@ static int dissect_tunnel_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree * opcode = tvb_get_guint8(tvb, offset + 3); if (opcode == 3) { - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset + 5, -1, -1); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset + 5, -1, -1); dissect_dof_common(next_tvb, pinfo, tree, &ref->api_data); } @@ -6097,7 +6097,7 @@ static int dissect_dof_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, * multiple DPS packets in a single Wireshark frame. */ { - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, packet_length, packet_length); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, packet_length, packet_length); tcp_dof_packet_ref *ref; gint raw_offset = tvb_raw_offset(tvb) + offset; gboolean ref_is_new = FALSE; @@ -6324,7 +6324,7 @@ static int dissect_tunnel_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre * multiple DPS packets in a single Wireshark frame. */ { - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, packet_length, packet_length); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, packet_length, packet_length); tcp_dof_packet_ref *ref; gint raw_offset = tvb_raw_offset(tvb) + offset; gboolean ref_is_new = FALSE; @@ -6678,7 +6678,7 @@ static int dissect_dnp_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo /* We have a packet. */ { - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, encapsulated_length, tvb_reported_length(tvb) - offset); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, encapsulated_length, tvb_reported_length(tvb) - offset); offset += dof_dissect_dpp_common(next_tvb, pinfo, proto_item_get_parent(tree), data); } } @@ -6819,7 +6819,7 @@ static int dissect_dpp_v2_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree * oid_tree = proto_tree_add_subtree(opid_tree, tvb, offset, 0, ett_2009_12_dpp_2_opid, NULL, "Source Identifier"); - next_tvb = tvb_new_subset(tvb, offset, -1, tvb_reported_length(tvb) - offset); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, tvb_reported_length(tvb) - offset); opid_len = call_dissector_only(dof_oid_handle, next_tvb, pinfo, oid_tree, NULL); learn_sender_sid(api_data, opid_len, tvb_get_ptr(next_tvb, 0, opid_len)); @@ -7004,7 +7004,7 @@ static int dissect_dpp_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo oid_tree = proto_tree_add_subtree(opid_tree, tvb, offset, 0, ett_2009_12_dpp_2_opid, NULL, "Source Identifier"); - next_tvb = tvb_new_subset(tvb, offset, -1, tvb_reported_length(tvb) - offset); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, tvb_reported_length(tvb) - offset); opid_len = call_dissector_only(dof_oid_handle, next_tvb, pinfo, oid_tree, NULL); proto_item_set_len(oid_tree, opid_len); @@ -7364,7 +7364,7 @@ static int dissect_dpp_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo */ { guint16 app; - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, -1, tvb_reported_length(tvb) - offset); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, tvb_reported_length(tvb) - offset); read_c2(tvb, offset, &app, NULL); if (app == 0x7FFF) @@ -7388,7 +7388,7 @@ static int dissect_options(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto while (offset < (gint)tvb_captured_length(tvb)) { proto_tree *subtree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_2008_1_dsp_12_option, NULL, "Option"); - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, -1); gint len = dissect_2008_1_dsp_1(next_tvb, pinfo, subtree); proto_item_set_len(proto_tree_get_parent(subtree), len); offset += len; @@ -7976,7 +7976,7 @@ static int dissect_ccm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * buffer we need to adjust the length of the existing buffer. */ g_free(buf); - app = tvb_new_subset(tvb, offset, e_len - session->mac_len, e_len - session->mac_len); + app = tvb_new_subset_length_caplen(tvb, offset, e_len - session->mac_len, e_len - session->mac_len); dof_packet->decrypted_tvb = app; dof_packet->decrypted_offset = 0; } @@ -8844,7 +8844,7 @@ static int dissect_sgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi offset = dof_dissect_pdu_as_field(dissect_2008_16_security_9, tvb, pinfo, sgmp_tree, offset, hf_initial_state, ett_initial_state, NULL); #if 0 /*TODO check this */ - initial_state = tvb_new_subset(tvb, start_offset, offset - start_offset, offset - start_offset); + initial_state = tvb_new_subset_length_caplen(tvb, start_offset, offset - start_offset, offset - start_offset); #endif } @@ -8994,7 +8994,7 @@ static int dissect_sgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi offset = dof_dissect_pdu_as_field(dissect_2008_16_security_9, tvb, pinfo, sgmp_tree, offset, hf_initial_state, ett_initial_state, NULL); #if 0 /*TODO check this */ - initial_state = tvb_new_subset(tvb, start_offset, offset - start_offset, offset - start_offset); + initial_state = tvb_new_subset_length_caplen(tvb, start_offset, offset - start_offset, offset - start_offset); #endif } @@ -9197,7 +9197,7 @@ static int dissect_sgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi { dof_secmode_api_data setup_data; gint block_length; - tvbuff_t *ntvb = tvb_new_subset(tvb, A_offset, -1, -1); + tvbuff_t *ntvb = tvb_new_subset_length_caplen(tvb, A_offset, -1, -1); setup_data.context = INITIALIZE; setup_data.security_mode_offset = 0; @@ -9300,7 +9300,7 @@ static int dissect_2008_4_tep_2_2_1(tvbuff_t *tvb, packet_info *pinfo, proto_tre /* Initial State */ { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); ti = proto_tree_add_item(tree, hf_tep_2_2_1_initial_state, tvb, offset, 0, ENC_NA); ti = proto_item_add_subtree(ti, ett_tep_2_2_1_initial_state); block_length = dof_dissect_pdu(dissect_2008_16_security_9, start, pinfo, ti, NULL); @@ -9585,7 +9585,7 @@ static int dissect_tep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void if (rekey_data && rekey_data->is_rekey) { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); ti = proto_tree_add_item(tep_tree, hf_tep_2_2_responder_initialization, tvb, offset, 0, ENC_NA); ti = proto_item_add_subtree(ti, ett_tep_2_2_responder_initialization); block_length = dissect_2008_4_tep_2_2_1(start, pinfo, ti, &ssid, data); @@ -12598,7 +12598,7 @@ static void dof_packet_delete_proto_data(dof_packet_data *packet, int proto) static gint dof_dissect_pdu_as_field(dissector_t dissector, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int item, int ett, void *result) { int block_length; - tvbuff_t *start = tvb_new_subset(tvb, offset, -1, -1); + tvbuff_t *start = tvb_new_subset_length_caplen(tvb, offset, -1, -1); proto_tree *my_tree; proto_item *ti = proto_tree_add_item(tree, item, tvb, offset, -1, ENC_NA); my_tree = proto_item_add_subtree(ti, ett); diff --git a/epan/dissectors/packet-e100.c b/epan/dissectors/packet-e100.c index bf2d042cee..82a83bad3d 100644 --- a/epan/dissectors/packet-e100.c +++ b/epan/dissectors/packet-e100.c @@ -117,7 +117,7 @@ dissect_e100(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ } /* if(tree) */ bytes_captured = tvb_get_ntohl(tvb, e100_bytes_cap.offset); bytes_original = tvb_get_ntohl(tvb, e100_bytes_orig.offset); - next_tvb = tvb_new_subset(tvb, e100_encap_len, bytes_captured, bytes_original); + next_tvb = tvb_new_subset_length_caplen(tvb, e100_encap_len, bytes_captured, bytes_original); call_dissector(eth_handle, next_tvb, pinfo, tree); return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-eap.c b/epan/dissectors/packet-eap.c index f4cfb49942..22d56fbdb7 100644 --- a/epan/dissectors/packet-eap.c +++ b/epan/dissectors/packet-eap.c @@ -1182,7 +1182,7 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) pinfo->fragmented = save_fragmented; } else { /* this data is NOT fragmented */ - next_tvb = tvb_new_subset(tvb, offset, tvb_len, size); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_len, size); call_dissector(ssl_handle, next_tvb, pinfo, eap_tree); } } diff --git a/epan/dissectors/packet-eigrp.c b/epan/dissectors/packet-eigrp.c index 5a72bf8b08..f678403337 100644 --- a/epan/dissectors/packet-eigrp.c +++ b/epan/dissectors/packet-eigrp.c @@ -1076,7 +1076,7 @@ dissect_eigrp_metric_flags (proto_tree *tree, tvbuff_t *tvb, int offset, int lim /* Decode the route flags field */ sub_tree = proto_tree_add_subtree(tree, tvb, offset, limit, ett_eigrp_metric_flags, NULL, "Flags"); - sub_tvb = tvb_new_subset(tvb, offset, limit, -1); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, limit, -1); /* just care about 'flags' byte, there are no MP flags for now */ proto_tree_add_item(sub_tree, hf_eigrp_metric_flags_srcwd, sub_tvb, 0, 1, @@ -1297,7 +1297,7 @@ dissect_eigrp_services (proto_item *ti, proto_tree *tree, tvbuff_t *tvb, remaining = tvb_captured_length_remaining(tvb, offset); sub_tree = proto_tree_add_subtree(tree, tvb, offset, remaining, ett_eigrp_tlv_metric, &sub_ti, "SAF Service "); - sub_tvb = tvb_new_subset(tvb, offset, remaining, -1); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, remaining, -1); sub_offset = 0; for (; tvb_reported_length_remaining(sub_tvb, sub_offset) > 0; ) { @@ -1332,7 +1332,7 @@ dissect_eigrp_services (proto_item *ti, proto_tree *tree, tvbuff_t *tvb, */ reach_tree = proto_tree_add_subtree(sub_tree, sub_tvb, sub_offset, 22, ett_eigrp_saf_reachability, NULL, "Reachability"); - reach_tvb = tvb_new_subset(sub_tvb, sub_offset, 22, -1); + reach_tvb = tvb_new_subset_length_caplen(sub_tvb, sub_offset, 22, -1); afi = tvb_get_ntohs(reach_tvb, 0); proto_tree_add_item(reach_tree, hf_eigrp_saf_reachability_afi, @@ -1427,7 +1427,7 @@ dissect_eigrp_legacy_metric (proto_tree *tree, tvbuff_t *tvb, int offset) tvbuff_t *sub_tvb; sub_tree = proto_tree_add_subtree(tree, tvb, offset, 16, ett_eigrp_tlv_metric, NULL, "Legacy Metric"); - sub_tvb = tvb_new_subset(tvb, offset, 16, -1); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, 16, -1); proto_tree_add_item(sub_tree, hf_eigrp_legacy_metric_delay, sub_tvb, 0, 4, ENC_BIG_ENDIAN); @@ -1488,7 +1488,7 @@ dissect_eigrp_ipx_extdata (proto_tree *tree, tvbuff_t *tvb, int offset) int sub_offset = 0; sub_tree = proto_tree_add_subtree(tree, tvb, offset, 20, ett_eigrp_tlv_extdata, NULL, "External Data"); - sub_tvb = tvb_new_subset(tvb, offset, 20, -1); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, 20, -1); /* Decode the external route source info */ proto_tree_add_item(sub_tree, hf_eigrp_ipx_extdata_routerid, sub_tvb, @@ -1555,7 +1555,7 @@ dissect_eigrp_extdata (proto_tree *tree, tvbuff_t *tvb, int offset) int sub_offset = 0; sub_tree = proto_tree_add_subtree(tree, tvb, offset, 20, ett_eigrp_tlv_extdata, NULL, "External Data"); - sub_tvb = tvb_new_subset(tvb, offset, 20, -1); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, 20, -1); /* Decode the external route source info */ proto_tree_add_item(sub_tree, hf_eigrp_extdata_origrid, sub_tvb, @@ -2145,7 +2145,7 @@ dissect_eigrp_wide_metric_attr (proto_tree *tree, tvbuff_t *tvb, limit *= 2; /* words to bytes */ sub_tree = proto_tree_add_subtree(tree, tvb, offset, limit, ett_eigrp_tlv_attr, NULL, "Attributes"); - sub_tvb = tvb_new_subset(tvb, offset, limit, -1); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, limit, -1); sub_offset = 0; while (limit > 0) { @@ -2175,7 +2175,7 @@ dissect_eigrp_wide_metric_attr (proto_tree *tree, tvbuff_t *tvb, case EIGRP_ATTR_COMM: dissect_eigrp_metric_comm(sub_tree, - tvb_new_subset(sub_tvb, sub_offset, 8, -1), + tvb_new_subset_length_caplen(sub_tvb, sub_offset, 8, -1), sub_offset, limit); break; @@ -2247,7 +2247,7 @@ dissect_eigrp_wide_metric (proto_tree *tree, tvbuff_t *tvb, int offset) guint64 big_num; sub_tree = proto_tree_add_subtree(tree, tvb, offset, 24, ett_eigrp_tlv_metric, NULL, "Wide Metric"); - sub_tvb = tvb_new_subset(tvb, offset, 24, -1); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, 24, -1); attr_size = tvb_get_guint8(sub_tvb, 0); diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index b8546a9185..918f386a78 100644 --- a/epan/dissectors/packet-epl.c +++ b/epan/dissectors/packet-epl.c @@ -2259,7 +2259,7 @@ dissect_epl_asnd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, guint8 size = tvb_captured_length_remaining(tvb, offset); reported_len = tvb_reported_length_remaining(tvb, offset); - next_tvb = tvb_new_subset(tvb, offset, size, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, size, reported_len); /* Manufacturer specific entries for ASND services */ if ( svid >= 0xA0 && svid < 0xFF ) { diff --git a/epan/dissectors/packet-erldp.c b/epan/dissectors/packet-erldp.c index 720d136113..e1f031cbbe 100644 --- a/epan/dissectors/packet-erldp.c +++ b/epan/dissectors/packet-erldp.c @@ -499,7 +499,7 @@ static int dissect_erldp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree break; case VERSION_MAGIC: - next_tvb = tvb_new_subset(tvb, offset, -1, 4 + msg_len - offset); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, 4 + msg_len - offset); offset += dissect_etf_pdu(next_tvb, pinfo, erldp_tree, "DistributionHeader"); if ((tvb_get_guint8(tvb, offset) == SMALL_TUPLE_EXT) && (tvb_get_guint8(tvb, offset + 2) == SMALL_INTEGER_EXT)) { ctl_op = tvb_get_guint8(tvb, offset + 3); diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c index a0b8b1a15d..1159e2289a 100644 --- a/epan/dissectors/packet-eth.c +++ b/epan/dissectors/packet-eth.c @@ -721,7 +721,7 @@ add_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, /* Create a new tvb without the padding and/or the (assumed) fcs */ if (fcs_len==4) - real_trailer_tvb = tvb_new_subset(trailer_tvb, padding_length, + real_trailer_tvb = tvb_new_subset_length_caplen(trailer_tvb, padding_length, trailer_length, trailer_reported_length); else real_trailer_tvb = tvb_new_subset_remaining(trailer_tvb, padding_length); @@ -788,7 +788,7 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) total_trailer_length = eth_trailer_length + (eth_assume_fcs ? 4 : 0); /* Dissect the tvb up to, but not including the trailer */ - next_tvb = tvb_new_subset(tvb, 0, + next_tvb = tvb_new_subset_length_caplen(tvb, 0, tvb_captured_length(tvb) - total_trailer_length, tvb_reported_length(tvb) - total_trailer_length); fh_tree = dissect_eth_common(next_tvb, pinfo, tree, 0); diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c index 485f008fb3..45e64be35c 100644 --- a/epan/dissectors/packet-ethertype.c +++ b/epan/dissectors/packet-ethertype.c @@ -251,7 +251,7 @@ dissect_ethertype(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat captured_length = reported_length; } } - next_tvb = tvb_new_subset(tvb, ethertype_data->offset_after_ethertype, captured_length, + next_tvb = tvb_new_subset_length_caplen(tvb, ethertype_data->offset_after_ethertype, captured_length, reported_length); p_add_proto_data(pinfo->pool, pinfo, proto_ethertype, 0, GUINT_TO_POINTER((guint)ethertype_data->etype)); diff --git a/epan/dissectors/packet-fcoe.c b/epan/dissectors/packet-fcoe.c index fee88470e4..a0b6617d1d 100644 --- a/epan/dissectors/packet-fcoe.c +++ b/epan/dissectors/packet-fcoe.c @@ -162,7 +162,7 @@ dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ bytes_remaining = tvb_captured_length_remaining(tvb, header_len); if (bytes_remaining > frame_len) bytes_remaining = frame_len; /* backing length */ - next_tvb = tvb_new_subset(tvb, header_len, bytes_remaining, frame_len); + next_tvb = tvb_new_subset_length_caplen(tvb, header_len, bytes_remaining, frame_len); eof_str = "none"; if (tvb_bytes_exist(tvb, eof_offset, 1)) { diff --git a/epan/dissectors/packet-fcp.c b/epan/dissectors/packet-fcp.c index 70029fc0cd..24588de17a 100644 --- a/epan/dissectors/packet-fcp.c +++ b/epan/dissectors/packet-fcp.c @@ -546,7 +546,7 @@ dissect_fcp_rsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, prot if (rsplen) { tvbuff_t *rspinfo_tvb; - rspinfo_tvb = tvb_new_subset(tvb, offset, MIN(rsplen, tvb_captured_length_remaining(tvb, offset)), rsplen); + rspinfo_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(rsplen, tvb_captured_length_remaining(tvb, offset)), rsplen); dissect_fcp_rspinfo(rspinfo_tvb, tree, 0); offset += rsplen; @@ -556,7 +556,7 @@ dissect_fcp_rsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, prot if (snslen) { tvbuff_t *sns_tvb; - sns_tvb = tvb_new_subset(tvb, offset, MIN(snslen, tvb_captured_length_remaining(tvb, offset)), snslen); + sns_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(snslen, tvb_captured_length_remaining(tvb, offset)), snslen); dissect_scsi_snsinfo(sns_tvb, pinfo, parent_tree, 0, snslen, (request_data != NULL) ? request_data->itlq : &empty_itlq, &itl); diff --git a/epan/dissectors/packet-fip.c b/epan/dissectors/packet-fip.c index bfbaf867fc..3f5595f9f8 100644 --- a/epan/dissectors/packet-fip.c +++ b/epan/dissectors/packet-fip.c @@ -440,7 +440,7 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) if (!tvb_bytes_exist(tvb, desc_offset, dlen) || dlen > rlen) { break; } - desc_tvb = tvb_new_subset(tvb, desc_offset, dlen, -1); + desc_tvb = tvb_new_subset_length_caplen(tvb, desc_offset, dlen, -1); dtype = tvb_get_guint8(desc_tvb, 0); desc_offset += dlen; rlen -= dlen; @@ -493,7 +493,7 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) fc_data_t fc_data = {ETHERTYPE_FIP, 0}; subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_caps, &item); - ls_tvb = tvb_new_subset(desc_tvb, 4, dlen - 4, -1); + ls_tvb = tvb_new_subset_length_caplen(desc_tvb, 4, dlen - 4, -1); call_dissector_with_data(fc_handle, ls_tvb, pinfo, subtree, &fc_data); proto_item_append_text(item, "%u bytes", dlen - 4); } diff --git a/epan/dissectors/packet-gsm_um.c b/epan/dissectors/packet-gsm_um.c index f8e77b433b..46f4678d6a 100644 --- a/epan/dissectors/packet-gsm_um.c +++ b/epan/dissectors/packet-gsm_um.c @@ -200,7 +200,7 @@ dissect_gsm_um(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _ len_left = tvb_reported_length(tvb); len_byte = tvb_get_guint8(tvb, 0); pseudo_len = len_byte >> 2; - next_tvb = tvb_new_subset(tvb, 1, MIN(len_left, pseudo_len), -1); + next_tvb = tvb_new_subset_length_caplen(tvb, 1, MIN(len_left, pseudo_len), -1); if (tree) { proto_tree_add_uint(gsm_um_tree, hf_gsm_um_l2_pseudo_len, tvb, 0, 1, diff --git a/epan/dissectors/packet-gtpv2.c b/epan/dissectors/packet-gtpv2.c index 810359b89a..6da409d5ae 100644 --- a/epan/dissectors/packet-gtpv2.c +++ b/epan/dissectors/packet-gtpv2.c @@ -4346,7 +4346,7 @@ dissect_complete_request_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree offset += 1; /* Add the Complete Request Message */ - new_tvb = tvb_new_subset(tvb, offset, length-1, length-1); + new_tvb = tvb_new_subset_length_caplen(tvb, offset, length-1, length-1); call_dissector(nas_eps_handle, new_tvb, pinfo, tree); } diff --git a/epan/dissectors/packet-h223.c b/epan/dissectors/packet-h223.c index edf38706f5..756eaac54a 100644 --- a/epan/dissectors/packet-h223.c +++ b/epan/dissectors/packet-h223.c @@ -1063,7 +1063,7 @@ dissect_mux_pdu( tvbuff_t *tvb, packet_info *pinfo, guint32 pkt_offset, } if(mpl > 0) { - pdu_tvb = tvb_new_subset(tvb, offset, len, mpl); + pdu_tvb = tvb_new_subset_length_caplen(tvb, offset, len, mpl); if(errors != -1) { dissect_mux_payload(pdu_tvb,pinfo,pkt_offset+offset,pdu_tree,call_info,mc,end_of_mux_sdu, ctype, circuit_id); } else { diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c index 7ca29fb2b1..f15a790c2c 100644 --- a/epan/dissectors/packet-h225.c +++ b/epan/dissectors/packet-h225.c @@ -3900,7 +3900,7 @@ dissect_h225_GenericIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac if (gefx) { ti = proto_tree_add_string(tree, hf_h225_debug_dissector_try_string, tvb, offset>>3, 0, gefx->key); PROTO_ITEM_SET_HIDDEN(ti); - dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); + dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset_length_caplen(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); } actx->private_data = gefx; /* subdissector could overwrite it */ diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c index 5b9f23a9cf..bc8d180694 100644 --- a/epan/dissectors/packet-h245.c +++ b/epan/dissectors/packet-h245.c @@ -3641,7 +3641,7 @@ dissect_h245_CapabilityIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t if (gefx) { ti = proto_tree_add_string(tree, hf_h245_debug_dissector_try_string, tvb, offset>>3, 0, gefx->key); PROTO_ITEM_SET_HIDDEN(ti); - dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); + dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset_length_caplen(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); } actx->private_data = gefx; /* subdissector could overwrite it */ @@ -3709,7 +3709,7 @@ dissect_h245_ParameterIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t * if (gefx) { ti = proto_tree_add_string(tree, hf_h245_debug_dissector_try_string, tvb, offset>>3, 0, gefx->key); PROTO_ITEM_SET_HIDDEN(ti); - dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); + dissector_try_string(gef_name_dissector_table, gefx->key, tvb_new_subset_length_caplen(tvb, offset>>3, 0, 0), actx->pinfo, tree, actx); } actx->private_data = gefx; /* subdissector could overwrite it */ diff --git a/epan/dissectors/packet-h264.c b/epan/dissectors/packet-h264.c index 133c817a7e..ad6be322d0 100644 --- a/epan/dissectors/packet-h264.c +++ b/epan/dissectors/packet-h264.c @@ -2116,7 +2116,7 @@ dissect_h264_pacsi(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint off else { /* Make a new subset of the existing buffer for the NAL unit */ - nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb,offset), nal_unit_size); + nalu_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb,offset), nal_unit_size); /* Decode the NAL unit */ dissect_h264(nalu_tvb, pinfo, tree, NULL); offset += nal_unit_size; @@ -2165,7 +2165,7 @@ dissect_h264_stap(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint else { /* Make a new subset of the existing buffer for the NAL unit */ - nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size); + nalu_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size); /* Decode the NAL unit */ dissect_h264(nalu_tvb, pinfo, tree, NULL); offset += nal_unit_size; @@ -2222,7 +2222,7 @@ dissect_h264_mtap(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint else { /* Make a new subset of the existing buffer for the NAL unit */ - nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size); + nalu_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size); /* Decode the NAL unit */ dissect_h264(nalu_tvb, pinfo, tree, NULL); offset += nal_unit_size; @@ -2288,7 +2288,7 @@ dissect_h264_nalu_extension (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo else { /* Make a new subset of the existing buffer for the NAL unit */ - nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size); + nalu_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size); /* Decode the NAL unit */ dissect_h264(nalu_tvb, pinfo, nimtap_tree, NULL); offset += nal_unit_size; diff --git a/epan/dissectors/packet-h450-ros.c b/epan/dissectors/packet-h450-ros.c index c17dbacb55..975254d2cf 100644 --- a/epan/dissectors/packet-h450-ros.c +++ b/epan/dissectors/packet-h450-ros.c @@ -246,7 +246,7 @@ dissect_h450_ros_Invoke(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size); if (!arg_next_tvb) { /* empty argument */ - arg_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + arg_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((arg_handle)?arg_handle:data_handle, arg_next_tvb, actx->pinfo, tree, actx->rose_ctx); @@ -330,7 +330,7 @@ dissect_h450_ros_ReturnResult(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act if (actx->rose_ctx->d.code != -1) { if (!res_next_tvb) { /* empty result */ - res_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + res_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((res_handle)?res_handle:data_handle, res_next_tvb, actx->pinfo, tree, actx->rose_ctx); @@ -399,7 +399,7 @@ dissect_h450_ros_ReturnError(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size); if (!err_next_tvb) { /* empty error */ - err_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + err_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((err_handle)?err_handle:data_handle, err_next_tvb, actx->pinfo, tree, actx->rose_ctx); diff --git a/epan/dissectors/packet-hiqnet.c b/epan/dissectors/packet-hiqnet.c index 382b26baee..72eb1d9261 100644 --- a/epan/dissectors/packet-hiqnet.c +++ b/epan/dissectors/packet-hiqnet.c @@ -1109,7 +1109,7 @@ dissect_hiqnet_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da if (captured_length > plen) captured_length = plen; - next_tvb = tvb_new_subset(tvb, offset, captured_length, plen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, captured_length, plen); dissect_hiqnet_pdu(next_tvb, pinfo, tree, data); diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index 64d1133c0e..34d2efa1db 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -1382,7 +1382,7 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo, * which, if no content length was specified, * is -1, i.e. "to the end of the frame. */ - next_tvb = tvb_new_subset(tvb, offset, datalen, + next_tvb = tvb_new_subset_length_caplen(tvb, offset, datalen, reported_datalen); /* @@ -1854,7 +1854,7 @@ chunked_encoding_dissector(tvbuff_t **tvb_ptr, packet_info *pinfo, if (new_tvb != NULL && chunk_size != 0) { tvbuff_t *chunk_tvb = NULL; - chunk_tvb = tvb_new_subset(tvb, chunk_offset, + chunk_tvb = tvb_new_subset_length_caplen(tvb, chunk_offset, chunk_size, datalen); tvb_composite_append(new_tvb, chunk_tvb); diff --git a/epan/dissectors/packet-iec104.c b/epan/dissectors/packet-iec104.c index 2a5b6871c5..3455a135d2 100644 --- a/epan/dissectors/packet-iec104.c +++ b/epan/dissectors/packet-iec104.c @@ -1464,7 +1464,7 @@ static int dissect_iec104apci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre proto_item_append_text(it104, ": %s", wmem_strbuf_get_str(res)); if (type == I_TYPE) - call_dissector(iec104asdu_handle, tvb_new_subset(tvb, Off + APCI_LEN, -1, len - APCI_DATA_LEN), pinfo, tree); + call_dissector(iec104asdu_handle, tvb_new_subset_length_caplen(tvb, Off + APCI_LEN, -1, len - APCI_DATA_LEN), pinfo, tree); /* Don't search more the APCI_START */ break; diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 807f84e868..c9eeaf880b 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -17968,7 +17968,7 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo, item=proto_tree_add_uint(hdr_tree, hf_ieee80211_fc_analysis_retransmission_frame, tvb, 0, 0, fnum); PROTO_ITEM_SET_GENERATED(item); } - next_tvb = tvb_new_subset(tvb, hdr_len, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, hdr_len, len, reported_len); call_data_dissector(next_tvb, pinfo, tree); goto end_of_wlan; } @@ -18195,7 +18195,7 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo, * WEP decode impossible or failed, treat payload as raw data * and don't attempt fragment reassembly or further dissection. */ - next_tvb = tvb_new_subset(tvb, hdr_len + ivlen, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, hdr_len + ivlen, len, reported_len); if (tree) { if (algorithm == PROTECTION_ALG_WEP) { @@ -18312,7 +18312,7 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo, /* First fragment, or not fragmented. Dissect what we have here. */ /* Get a tvbuff for the payload. */ - next_tvb = tvb_new_subset(next_tvb, hdr_len, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(next_tvb, hdr_len, len, reported_len); /* * If this is the first fragment, but not the only fragment, @@ -18328,7 +18328,7 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo, if (next_tvb == NULL) { /* Just show this as an incomplete fragment. */ col_set_str(pinfo->cinfo, COL_INFO, "Fragmented IEEE 802.11 frame"); - next_tvb = tvb_new_subset(tvb, hdr_len, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, hdr_len, len, reported_len); call_data_dissector(next_tvb, pinfo, tree); pinfo->fragmented = save_fragmented; goto end_of_wlan; diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c index 05a42ff284..3ef8189049 100644 --- a/epan/dissectors/packet-ieee802154.c +++ b/epan/dissectors/packet-ieee802154.c @@ -807,7 +807,7 @@ dissect_ieee802154_nonask_phy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre } offset+=4+2*1; - mac=tvb_new_subset(tvb,offset,-1, phr & IEEE802154_PHY_LENGTH_MASK); + mac=tvb_new_subset_length_caplen(tvb,offset,-1, phr & IEEE802154_PHY_LENGTH_MASK); /* Call the common dissector. */ dissect_ieee802154(mac, pinfo, ieee802154_tree, NULL); @@ -862,7 +862,7 @@ dissect_ieee802154_nofcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo * checks to ensure that the new reported length is not longer than the old * reported length (why?), and will throw an exception. */ - new_tvb = tvb_new_subset(tvb, 0, -1, tvb_reported_length(tvb)+IEEE802154_FCS_LEN); + new_tvb = tvb_new_subset_length_caplen(tvb, 0, -1, tvb_reported_length(tvb)+IEEE802154_FCS_LEN); /* Call the common dissector. */ dissect_ieee802154_common(new_tvb, pinfo, tree, 0); return tvb_captured_length(tvb); @@ -906,7 +906,7 @@ dissect_zboss_specific(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree) proto_tree_add_item(zboss_tree, zboss_trace_number, tvb, off, 4, ENC_LITTLE_ENDIAN); off += 4; - return tvb_new_subset(tvb, off, tvb_captured_length(tvb) - off, tvb_captured_length(tvb) - off); + return tvb_new_subset_length_caplen(tvb, off, tvb_captured_length(tvb) - off, tvb_captured_length(tvb) - off); } } return tvb; @@ -1518,7 +1518,7 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g gint reported_len = tvb_reported_length(tvb)-offset-IEEE802154_FCS_LEN; gint captured_len = tvb_captured_length(tvb)-offset; if (reported_len < captured_len) captured_len = reported_len; - payload_tvb = tvb_new_subset(tvb, offset, captured_len, reported_len); + payload_tvb = tvb_new_subset_length_caplen(tvb, offset, captured_len, reported_len); } /* Display the reason for failure, and abort if the error was fatal. */ @@ -1573,7 +1573,7 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g gint reported_len = tvb_reported_length(tvb)-offset-IEEE802154_FCS_LEN; gint captured_len = tvb_captured_length(tvb)-offset; if (reported_len < captured_len) captured_len = reported_len; - payload_tvb = tvb_new_subset(tvb, offset, captured_len, reported_len); + payload_tvb = tvb_new_subset_length_caplen(tvb, offset, captured_len, reported_len); } /* presense of Payload IEs is defined by the termination of the Header IEs */ @@ -3060,7 +3060,7 @@ dissect_ieee802154_decrypt(tvbuff_t *tvb, guint offset, packet_info *pinfo, ieee } /* Create a tvbuff for the plaintext. This might result in a zero-length tvbuff. */ - ptext_tvb = tvb_new_subset(tvb, offset, captured_len, reported_len); + ptext_tvb = tvb_new_subset_length_caplen(tvb, offset, captured_len, reported_len); *status = DECRYPT_PACKET_SUCCEEDED; } diff --git a/epan/dissectors/packet-ieee8023.c b/epan/dissectors/packet-ieee8023.c index bfc28bc0d4..a79f6f92c4 100644 --- a/epan/dissectors/packet-ieee8023.c +++ b/epan/dissectors/packet-ieee8023.c @@ -78,7 +78,7 @@ dissect_802_3(volatile int length, gboolean is_802_2, tvbuff_t *tvb, captured_length = tvb_captured_length_remaining(tvb, offset_after_length); if (captured_length > length) captured_length = length; - next_tvb = tvb_new_subset(tvb, offset_after_length, captured_length, length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset_after_length, captured_length, length); /* Dissect the payload either as IPX or as an LLC frame. Catch non-fatal exceptions, so that if the reported length diff --git a/epan/dissectors/packet-igrp.c b/epan/dissectors/packet-igrp.c index e1bcb32eed..78beb8a249 100644 --- a/epan/dissectors/packet-igrp.c +++ b/epan/dissectors/packet-igrp.c @@ -126,7 +126,7 @@ static int dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi ti = proto_tree_add_item(igrp_tree, hf_igrp_interior_routes, tvb, 4, 2, ENC_BIG_ENDIAN); for( ; ninterior>0 ; ninterior-- ) { igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); - next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, IGRP_ENTRY_LENGTH, -1); dissect_vektor_igrp (next_tvb,igrp_vektor_tree,network); offset+=IGRP_ENTRY_LENGTH; } @@ -134,7 +134,7 @@ static int dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi ti = proto_tree_add_item(igrp_tree, hf_igrp_system_routes, tvb, 6, 2, ENC_BIG_ENDIAN); for( ; nsystem>0 ; nsystem-- ) { igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); - next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, IGRP_ENTRY_LENGTH, -1); dissect_vektor_igrp (next_tvb,igrp_vektor_tree,0); offset+=IGRP_ENTRY_LENGTH; } @@ -142,7 +142,7 @@ static int dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi ti = proto_tree_add_item(igrp_tree, hf_igrp_exterior_routes, tvb, 8, 2, ENC_BIG_ENDIAN); for( ; nexterior>0 ; nexterior-- ) { igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); - next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, IGRP_ENTRY_LENGTH, -1); dissect_vektor_igrp (next_tvb,igrp_vektor_tree,0); offset+=IGRP_ENTRY_LENGTH; } diff --git a/epan/dissectors/packet-ipmi-session.c b/epan/dissectors/packet-ipmi-session.c index a62639e82c..ebe9e9d794 100644 --- a/epan/dissectors/packet-ipmi-session.c +++ b/epan/dissectors/packet-ipmi-session.c @@ -222,7 +222,7 @@ dissect_ipmi_session(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * } /* If we can parse the embedded message, do so */ - next_tvb = tvb_new_subset(tvb, msg_start, msg_len, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, msg_start, msg_len, -1); if (payloadtype_enc) { /* This is RMCP+, and payload is encrypted. In this case, there is a 'confidentiality header/trailer', whose lengths diff --git a/epan/dissectors/packet-ipsec-tcp.c b/epan/dissectors/packet-ipsec-tcp.c index fd4e333cb4..9386e41fef 100644 --- a/epan/dissectors/packet-ipsec-tcp.c +++ b/epan/dissectors/packet-ipsec-tcp.c @@ -147,7 +147,7 @@ dissect_tcpencap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data } /* Create the tvbuffer for the next dissector */ - next_tvb = tvb_new_subset(tvb, 0, reported_length - TRAILERLENGTH , -1); + next_tvb = tvb_new_subset_length_caplen(tvb, 0, reported_length - TRAILERLENGTH , -1); if (protocol == TCP_ENCAP_P_UDP) { call_dissector(udp_handle, next_tvb, pinfo, tree); } else { /* Hopefully ESP */ diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 0d13dc9476..9ce911dc14 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -2103,7 +2103,7 @@ dissect_esp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) */ if(!g_esp_enable_encryption_decode && g_esp_enable_authentication_check && sad_is_present) { - next_tvb = tvb_new_subset(tvb, 8, len - 8 - esp_auth_len, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, 8, len - 8 - esp_auth_len, -1); export_ipsec_pdu(data_handle, pinfo, next_tvb); call_dissector(data_handle, next_tvb, pinfo, esp_tree); diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index 9d9dcacba3..5498a283c7 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -1532,7 +1532,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off tvb_rlen=tvb_reported_length_remaining(tvb, offset); if(tvb_rlen>snsl) tvb_rlen=snsl; - data_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen); + data_tvb=tvb_new_subset_length_caplen(tvb, offset, tvb_len, tvb_rlen); dissect_scsi_snsinfo (data_tvb, pinfo, tree, 0, tvb_len, &cdata->itlq, itl); @@ -1672,7 +1672,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off if(tvb_rlen>16){ tvb_rlen=16; } - cdb_tvb=tvb_new_subset(tvb, cdb_offset, tvb_len, tvb_rlen); + cdb_tvb=tvb_new_subset_length_caplen(tvb, cdb_offset, tvb_len, tvb_rlen); } dissect_scsi_cdb(cdb_tvb, pinfo, tree, SCSI_DEV_UNKNOWN, &cdata->itlq, itl); /* we don't want the immediate below to overwrite our CDB info */ @@ -1687,7 +1687,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off tvb_rlen=tvb_reported_length_remaining(tvb, immediate_data_offset); if(tvb_rlen>(int)immediate_data_length) tvb_rlen=immediate_data_length; - data_tvb=tvb_new_subset(tvb, immediate_data_offset, tvb_len, tvb_rlen); + data_tvb=tvb_new_subset_length_caplen(tvb, immediate_data_offset, tvb_len, tvb_rlen); dissect_scsi_payload (data_tvb, pinfo, tree, TRUE, &cdata->itlq, itl, @@ -1713,7 +1713,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off tvb_rlen=tvb_reported_length_remaining(tvb, offset); if(tvb_rlen>senseLen) tvb_rlen=senseLen; - data_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen); + data_tvb=tvb_new_subset_length_caplen(tvb, offset, tvb_len, tvb_rlen); dissect_scsi_snsinfo (data_tvb, pinfo, tree, 0, tvb_len, &cdata->itlq, itl); @@ -1736,7 +1736,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off tvb_rlen=tvb_reported_length_remaining(tvb, offset); if(tvb_rlen>(int)data_segment_len) tvb_rlen=data_segment_len; - data_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen); + data_tvb=tvb_new_subset_length_caplen(tvb, offset, tvb_len, tvb_rlen); dissect_scsi_payload (data_tvb, pinfo, tree, (opcode==ISCSI_OPCODE_SCSI_DATA_OUT), &cdata->itlq, itl, diff --git a/epan/dissectors/packet-isi.c b/epan/dissectors/packet-isi.c index 2393af806d..fae1635a69 100644 --- a/epan/dissectors/packet-isi.c +++ b/epan/dissectors/packet-isi.c @@ -917,7 +917,7 @@ static int dissect_isi_sim(tvbuff_t *tvb, packet_info *pinfo, proto_item *isitre proto_tree_add_item(tree, hf_isi_sim_imsi_length, tvb, 3, 1, ENC_BIG_ENDIAN); /* - next_tvb = tvb_new_subset(tvb, 0, -1, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, 0, -1, -1); proto_tree_add_item(tree, hf_isi_sim_imsi_byte_1, next_tvb, 4, 1, ENC_LITTLE_ENDIAN); dissect_e212_mcc_mnc(next_tvb, pinfo, tree, 4, FALSE ); proto_tree_add_item(tree, hf_E212_msin, tvb, 2, 7, FALSE); diff --git a/epan/dissectors/packet-isl.c b/epan/dissectors/packet-isl.c index 862c4dbafd..8d001966d3 100644 --- a/epan/dissectors/packet-isl.c +++ b/epan/dissectors/packet-isl.c @@ -202,7 +202,7 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len) the packet doesn't have "length" bytes worth of captured data left in it - or it may not even have "length" bytes worth of data in it, period - - so the "tvb_new_subset()" creating "payload_tvb" + so the "tvb_new_subset_length_caplen()" creating "payload_tvb" threw an exception or @@ -214,7 +214,7 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len) In either case, this means that all the data in the frame is within the length value, so we give all the data to the next protocol and have no trailer. */ - payload_tvb = tvb_new_subset(tvb, 14, -1, length); + payload_tvb = tvb_new_subset_length_caplen(tvb, 14, -1, length); trailer_tvb = NULL; } ENDTRY; @@ -263,7 +263,7 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len) if (captured_length > length) captured_length = length; - next_tvb = tvb_new_subset(payload_tvb, 12, captured_length, length); + next_tvb = tvb_new_subset_length_caplen(payload_tvb, 12, captured_length, length); /* Dissect the payload as an Ethernet frame. diff --git a/epan/dissectors/packet-iso15765.c b/epan/dissectors/packet-iso15765.c index d33d014c27..57df76f713 100644 --- a/epan/dissectors/packet-iso15765.c +++ b/epan/dissectors/packet-iso15765.c @@ -227,7 +227,7 @@ dissect_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data case ISO15765_MESSAGE_TYPES_SINGLE_FRAME: { offset = ae + ISO15765_PCI_OFFSET + ISO15765_PCI_LEN; data_length = masked_guint8_value(pci, ISO15765_MESSAGE_DATA_LENGTH_MASK); - next_tvb = tvb_new_subset(tvb, offset, data_length, data_length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, data_length, data_length); complete = TRUE; /* Show some info */ @@ -366,7 +366,7 @@ dissect_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data next_tvb = new_tvb; complete = TRUE; } else { - next_tvb = tvb_new_subset(tvb, offset, data_length, data_length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, data_length, data_length); } } } diff --git a/epan/dissectors/packet-isup.c b/epan/dissectors/packet-isup.c index 82b26dd899..2d8af48dab 100644 --- a/epan/dissectors/packet-isup.c +++ b/epan/dissectors/packet-isup.c @@ -7979,7 +7979,7 @@ dissect_isup_optional_parameter(tvbuff_t *optional_parameters_tvb, packet_info * actual_length = tvb_reported_length_remaining(optional_parameters_tvb, offset); if (actual_length > 0) { - parameter_tvb = tvb_new_subset(optional_parameters_tvb, offset, MIN(parameter_length, actual_length), parameter_length); + parameter_tvb = tvb_new_subset_length_caplen(optional_parameters_tvb, offset, MIN(parameter_length, actual_length), parameter_length); switch (parameter_type) { case PARAM_TYPE_CALL_REF: dissect_isup_call_reference_parameter(parameter_tvb, parameter_tree, parameter_item); @@ -8336,7 +8336,7 @@ dissect_ansi_isup_optional_parameter(tvbuff_t *optional_parameters_tvb, packet_i actual_length = tvb_reported_length_remaining(optional_parameters_tvb, offset); if (actual_length > 0) { - parameter_tvb = tvb_new_subset(optional_parameters_tvb, offset, MIN(parameter_length, actual_length), parameter_length); + parameter_tvb = tvb_new_subset_length_caplen(optional_parameters_tvb, offset, MIN(parameter_length, actual_length), parameter_length); switch (parameter_type) { case PARAM_TYPE_CALL_REF: dissect_isup_call_reference_parameter(parameter_tvb, parameter_tree, parameter_item); @@ -8643,7 +8643,7 @@ dissect_ansi_isup_circuit_validation_test_resp_message(tvbuff_t *message_tvb, pr actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(CVR_RESP_IND_LENGTH, actual_length), CVR_RESP_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(CVR_RESP_IND_LENGTH, actual_length), CVR_RESP_IND_LENGTH); dissect_isup_cvr_response_ind_parameter(parameter_tvb, parameter_tree, parameter_item); offset += CVR_RESP_IND_LENGTH; @@ -8657,7 +8657,7 @@ dissect_ansi_isup_circuit_validation_test_resp_message(tvbuff_t *message_tvb, pr parameter_type, val_to_str_ext_const(parameter_type, &isup_parameter_type_value_ext, "Circuit Group Characters")); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(CG_CHAR_IND_LENGTH, actual_length), CG_CHAR_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(CG_CHAR_IND_LENGTH, actual_length), CG_CHAR_IND_LENGTH); dissect_isup_circuit_group_char_ind_parameter(parameter_tvb, parameter_tree, parameter_item); offset += CG_CHAR_IND_LENGTH; @@ -8682,7 +8682,7 @@ dissect_ansi_isup_circuit_reservation_message(tvbuff_t *message_tvb, proto_tree "Nature of Connection Indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(NATURE_OF_CONNECTION_IND_LENGTH, actual_length), NATURE_OF_CONNECTION_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(NATURE_OF_CONNECTION_IND_LENGTH, actual_length), NATURE_OF_CONNECTION_IND_LENGTH); dissect_isup_nature_of_connection_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += NATURE_OF_CONNECTION_IND_LENGTH; @@ -8707,7 +8707,7 @@ dissect_isup_initial_address_message(tvbuff_t *message_tvb, packet_info *pinfo, "Nature of Connection Indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(NATURE_OF_CONNECTION_IND_LENGTH, actual_length), NATURE_OF_CONNECTION_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(NATURE_OF_CONNECTION_IND_LENGTH, actual_length), NATURE_OF_CONNECTION_IND_LENGTH); dissect_isup_nature_of_connection_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += NATURE_OF_CONNECTION_IND_LENGTH; @@ -8718,7 +8718,7 @@ dissect_isup_initial_address_message(tvbuff_t *message_tvb, packet_info *pinfo, "Forward Call Indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(FORWARD_CALL_IND_LENGTH, actual_length), FORWARD_CALL_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(FORWARD_CALL_IND_LENGTH, actual_length), FORWARD_CALL_IND_LENGTH); dissect_isup_forward_call_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += FORWARD_CALL_IND_LENGTH; @@ -8730,7 +8730,7 @@ dissect_isup_initial_address_message(tvbuff_t *message_tvb, packet_info *pinfo, "Calling Party's category"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(CALLING_PRTYS_CATEGORY_LENGTH, actual_length), CALLING_PRTYS_CATEGORY_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(CALLING_PRTYS_CATEGORY_LENGTH, actual_length), CALLING_PRTYS_CATEGORY_LENGTH); dissect_isup_calling_partys_category_parameter(parameter_tvb, parameter_tree, parameter_item, itu_isup_variant); offset += CALLING_PRTYS_CATEGORY_LENGTH; @@ -8744,7 +8744,7 @@ dissect_isup_initial_address_message(tvbuff_t *message_tvb, packet_info *pinfo, "Transmission medium requirement"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(TRANSMISSION_MEDIUM_REQUIREMENT_LENGTH, actual_length), TRANSMISSION_MEDIUM_REQUIREMENT_LENGTH); @@ -8767,7 +8767,7 @@ dissect_isup_initial_address_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -8792,7 +8792,7 @@ dissect_isup_initial_address_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -8829,7 +8829,7 @@ static gint dissect_isup_subsequent_address_message(tvbuff_t *message_tvb, packe proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -8858,7 +8858,7 @@ dissect_isup_information_request_message(tvbuff_t *message_tvb, proto_tree *isup "Information request indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(INFO_REQUEST_IND_LENGTH, actual_length), INFO_REQUEST_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(INFO_REQUEST_IND_LENGTH, actual_length), INFO_REQUEST_IND_LENGTH); dissect_isup_information_request_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += INFO_REQUEST_IND_LENGTH; return offset; @@ -8883,7 +8883,7 @@ dissect_isup_information_message(tvbuff_t *message_tvb, proto_tree *isup_tree) "Information indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(INFO_IND_LENGTH, actual_length), INFO_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(INFO_IND_LENGTH, actual_length), INFO_IND_LENGTH); dissect_isup_information_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += INFO_IND_LENGTH; return offset; @@ -8907,7 +8907,7 @@ dissect_isup_continuity_message(tvbuff_t *message_tvb, proto_tree *isup_tree) "Continuity indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(CONTINUITY_IND_LENGTH, actual_length), CONTINUITY_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(CONTINUITY_IND_LENGTH, actual_length), CONTINUITY_IND_LENGTH); dissect_isup_continuity_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += CONTINUITY_IND_LENGTH; return offset; @@ -8931,7 +8931,7 @@ dissect_isup_address_complete_message(tvbuff_t *message_tvb, proto_tree *isup_tr "Backward Call Indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(BACKWARD_CALL_IND_LENGTH, actual_length), BACKWARD_CALL_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(BACKWARD_CALL_IND_LENGTH, actual_length), BACKWARD_CALL_IND_LENGTH); dissect_isup_backward_call_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += BACKWARD_CALL_IND_LENGTH; return offset; @@ -8955,7 +8955,7 @@ dissect_isup_connect_message(tvbuff_t *message_tvb, proto_tree *isup_tree) "Backward Call Indicators"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(BACKWARD_CALL_IND_LENGTH, actual_length), BACKWARD_CALL_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(BACKWARD_CALL_IND_LENGTH, actual_length), BACKWARD_CALL_IND_LENGTH); dissect_isup_backward_call_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += BACKWARD_CALL_IND_LENGTH; return offset; @@ -8989,7 +8989,7 @@ dissect_isup_release_message(tvbuff_t *message_tvb, proto_tree *isup_tree) proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9025,7 +9025,7 @@ dissect_isup_suspend_resume_message(tvbuff_t *message_tvb, proto_tree *isup_tree "Suspend/Resume indicator"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(SUSPEND_RESUME_IND_LENGTH, actual_length), SUSPEND_RESUME_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(SUSPEND_RESUME_IND_LENGTH, actual_length), SUSPEND_RESUME_IND_LENGTH); dissect_isup_suspend_resume_indicators_parameter(parameter_tvb, parameter_tree, parameter_item); offset += SUSPEND_RESUME_IND_LENGTH; return offset; @@ -9059,7 +9059,7 @@ dissect_isup_circuit_group_reset_query_message(tvbuff_t *message_tvb, packet_inf proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9088,7 +9088,7 @@ dissect_isup_circuit_group_blocking_messages(tvbuff_t *message_tvb, packet_info "Circuit group supervision message type"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(CIRC_GRP_SV_MSG_TYPE_LENGTH, actual_length), CIRC_GRP_SV_MSG_TYPE_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(CIRC_GRP_SV_MSG_TYPE_LENGTH, actual_length), CIRC_GRP_SV_MSG_TYPE_LENGTH); dissect_isup_circuit_group_supervision_message_type_parameter(parameter_tvb, parameter_tree, parameter_item); offset += CIRC_GRP_SV_MSG_TYPE_LENGTH; @@ -9109,7 +9109,7 @@ dissect_isup_circuit_group_blocking_messages(tvbuff_t *message_tvb, packet_info proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9138,7 +9138,7 @@ dissect_isup_facility_request_accepted_message(tvbuff_t *message_tvb, proto_tree "Facility indicator"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(FACILITY_IND_LENGTH, actual_length), FACILITY_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(FACILITY_IND_LENGTH, actual_length), FACILITY_IND_LENGTH); dissect_isup_facility_ind_parameter(parameter_tvb, parameter_item); offset += FACILITY_IND_LENGTH; return offset; @@ -9163,7 +9163,7 @@ dissect_isup_facility_reject_message(tvbuff_t *message_tvb, proto_tree *isup_tre "Facility indicator"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(FACILITY_IND_LENGTH, actual_length), FACILITY_IND_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(FACILITY_IND_LENGTH, actual_length), FACILITY_IND_LENGTH); dissect_isup_facility_ind_parameter(parameter_tvb, parameter_item); offset += FACILITY_IND_LENGTH; @@ -9184,7 +9184,7 @@ dissect_isup_facility_reject_message(tvbuff_t *message_tvb, proto_tree *isup_tre proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9229,7 +9229,7 @@ dissect_isup_circuit_group_reset_acknowledgement_message(tvbuff_t *message_tvb, proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9267,7 +9267,7 @@ dissect_isup_circuit_group_query_response_message(tvbuff_t *message_tvb, packet_ proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9291,7 +9291,7 @@ dissect_isup_circuit_group_query_response_message(tvbuff_t *message_tvb, packet_ proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9319,7 +9319,7 @@ dissect_isup_call_progress_message(tvbuff_t *message_tvb, proto_tree *isup_tree) "Event information"); proto_tree_add_uint(parameter_tree, hf_isup_mand_parameter_type, message_tvb, 0, 0, parameter_type); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(EVENT_INFO_LENGTH, actual_length), EVENT_INFO_LENGTH); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(EVENT_INFO_LENGTH, actual_length), EVENT_INFO_LENGTH); dissect_isup_event_information_parameter(parameter_tvb, parameter_tree, parameter_item); offset += EVENT_INFO_LENGTH; return offset; @@ -9353,7 +9353,7 @@ dissect_isup_user_to_user_information_message(tvbuff_t *message_tvb, packet_info proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9392,7 +9392,7 @@ dissect_isup_confusion_message(tvbuff_t *message_tvb, proto_tree *isup_tree) message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); @@ -9545,7 +9545,7 @@ dissect_japan_chg_inf(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *isu parameter_type, val_to_str_ext_const(parameter_type, &japan_isup_parameter_type_value_ext, "unknown")); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, offset, MIN(1, actual_length), 1); + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset, MIN(1, actual_length), 1); chg_inf_type = tvb_get_guint8(parameter_tvb, 0); dissect_japan_chg_inf_type(parameter_tvb, parameter_tree, parameter_item); offset += 1; @@ -9569,7 +9569,7 @@ dissect_japan_chg_inf(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *isu proto_tree_add_uint(parameter_tree, hf_isup_parameter_length, message_tvb, offset + parameter_pointer, PARAMETER_LENGTH_IND_LENGTH, parameter_length); actual_length = tvb_ensure_captured_length_remaining(message_tvb, offset); - parameter_tvb = tvb_new_subset(message_tvb, + parameter_tvb = tvb_new_subset_length_caplen(message_tvb, offset + parameter_pointer + PARAMETER_LENGTH_IND_LENGTH, MIN(parameter_length, actual_length), parameter_length); diff --git a/epan/dissectors/packet-kdsp.c b/epan/dissectors/packet-kdsp.c index e26586b42d..120d64c9ca 100644 --- a/epan/dissectors/packet-kdsp.c +++ b/epan/dissectors/packet-kdsp.c @@ -423,7 +423,7 @@ dissect_kdsp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* } payload_len = (length + FRAME_HEADER_LEN) - offset; if (cptbitmap & DATA_PACKLEN_FLAG) { - payload_tvb = tvb_new_subset(tvb, offset, payload_len, reported_payload_len); + payload_tvb = tvb_new_subset_length_caplen(tvb, offset, payload_len, reported_payload_len); if (cptbitmap & DATA_DLT_FLAG) { dissector_try_uint(subdissector_dlt_table, datalink_type, payload_tvb, pinfo, tree); diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c index 469da00b48..88d3113b5f 100644 --- a/epan/dissectors/packet-kerberos.c +++ b/epan/dissectors/packet-kerberos.c @@ -2051,7 +2051,7 @@ dissect_krb5_AD_WIN2K_PAC_struct(proto_tree *tree, tvbuff_t *tvb, int offset, as proto_tree_add_uint(tr, hf_krb_w2k_pac_offset, tvb, offset, 4, pac_offset); offset += 8; - next_tvb=tvb_new_subset(tvb, pac_offset, pac_size, pac_size); + next_tvb=tvb_new_subset_length_caplen(tvb, pac_offset, pac_size, pac_size); switch(pac_type){ case PAC_LOGON_INFO: dissect_krb5_PAC_LOGON_INFO(tr, next_tvb, 0, actx); diff --git a/epan/dissectors/packet-kink.c b/epan/dissectors/packet-kink.c index c7cd83928a..5457e09da0 100644 --- a/epan/dissectors/packet-kink.c +++ b/epan/dissectors/packet-kink.c @@ -356,7 +356,7 @@ dissect_payload_kink_ap_req(packet_info *pinfo, tvbuff_t *tvb, int offset, proto tvbuff_t *krb_tvb; krb_ap_req_length = payload_length - PAYLOAD_HEADER; - krb_tvb=tvb_new_subset(tvb, offset, (krb_ap_req_length>tvb_captured_length_remaining(tvb, offset))?tvb_captured_length_remaining(tvb, offset):krb_ap_req_length, krb_ap_req_length); + krb_tvb=tvb_new_subset_length_caplen(tvb, offset, (krb_ap_req_length>tvb_captured_length_remaining(tvb, offset))?tvb_captured_length_remaining(tvb, offset):krb_ap_req_length, krb_ap_req_length); keytype=kerberos_output_keytype(); dissect_kerberos_main(krb_tvb, pinfo, payload_kink_ap_req_tree, FALSE, NULL); /*offset += krb_ap_req_length;*/ @@ -411,7 +411,7 @@ dissect_payload_kink_ap_rep(packet_info *pinfo, tvbuff_t *tvb, int offset, proto tvbuff_t *krb_tvb; krb_ap_rep_length = payload_length - PAYLOAD_HEADER; - krb_tvb=tvb_new_subset(tvb, offset, (krb_ap_rep_length>tvb_captured_length_remaining(tvb, offset))?tvb_captured_length_remaining(tvb, offset):krb_ap_rep_length, krb_ap_rep_length); + krb_tvb=tvb_new_subset_length_caplen(tvb, offset, (krb_ap_rep_length>tvb_captured_length_remaining(tvb, offset))?tvb_captured_length_remaining(tvb, offset):krb_ap_rep_length, krb_ap_rep_length); keytype=kerberos_output_keytype(); dissect_kerberos_main(krb_tvb, pinfo, payload_kink_ap_rep_tree, FALSE, NULL); @@ -464,7 +464,7 @@ dissect_payload_kink_krb_error(packet_info *pinfo, tvbuff_t *tvb, int offset, pr tvbuff_t *krb_tvb; krb_error_length = payload_length - KINK_KRB_ERROR_HEADER; - krb_tvb=tvb_new_subset(tvb, offset, (krb_error_length>tvb_captured_length_remaining(tvb, offset))?tvb_captured_length_remaining(tvb, offset):krb_error_length, krb_error_length); + krb_tvb=tvb_new_subset_length_caplen(tvb, offset, (krb_error_length>tvb_captured_length_remaining(tvb, offset))?tvb_captured_length_remaining(tvb, offset):krb_error_length, krb_error_length); dissect_kerberos_main(krb_tvb, pinfo, payload_kink_krb_error_tree, FALSE, NULL); /*offset += krb_error_length;*/ @@ -630,7 +630,7 @@ dissect_payload_kink_isakmp(packet_info *pinfo, tvbuff_t *tvb, int offset, proto reported_length = tvb_reported_length_remaining(tvb, offset); if (reported_length > (int)isakmp_length) reported_length = isakmp_length; - isakmp_tvb = tvb_new_subset(tvb, offset, length, reported_length); + isakmp_tvb = tvb_new_subset_length_caplen(tvb, offset, length, reported_length); isakmp_dissect_payloads(isakmp_tvb, payload_kink_isakmp_tree, 1, inner_next_pload, 0, isakmp_length, pinfo); } @@ -688,7 +688,7 @@ dissect_payload_kink_encrypt(packet_info *pinfo, tvbuff_t *tvb, int offset, prot tvbuff_t *next_tvb; guint8 *plaintext=NULL; - next_tvb=tvb_new_subset(tvb, offset, MIN(tvb_captured_length_remaining(tvb, offset), encrypt_length), encrypt_length); + next_tvb=tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_captured_length_remaining(tvb, offset), encrypt_length), encrypt_length); plaintext=decrypt_krb5_data(tree, pinfo, 0, next_tvb, keytype, NULL); if(plaintext){ next_tvb=tvb_new_child_real_data(tvb, plaintext, encrypt_length, encrypt_length); diff --git a/epan/dissectors/packet-lapdm.c b/epan/dissectors/packet-lapdm.c index c5abe86982..d7dc18c950 100644 --- a/epan/dissectors/packet-lapdm.c +++ b/epan/dissectors/packet-lapdm.c @@ -287,7 +287,7 @@ dissect_lapdm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U if( !MIN(len, available_length) ) return 2; - payload = tvb_new_subset(tvb, LAPDM_HEADER_LEN, MIN(len,available_length), len); + payload = tvb_new_subset_length_caplen(tvb, LAPDM_HEADER_LEN, MIN(len,available_length), len); /* Potentially segmented I frame */ diff --git a/epan/dissectors/packet-lapsat.c b/epan/dissectors/packet-lapsat.c index 97cd2ee130..5527ef9246 100644 --- a/epan/dissectors/packet-lapsat.c +++ b/epan/dissectors/packet-lapsat.c @@ -512,7 +512,7 @@ dissect_lapsat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dissec payload = tvb_new_child_real_data(tvb, data, plen, plen); } else { /* Last nibble doesn't need merging */ - payload = tvb_new_subset(tvb, hlen, plen, plen); + payload = tvb_new_subset_length_caplen(tvb, hlen, plen, plen); } add_new_data_source(pinfo, payload, "LAPSat Payload"); diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 17b54f4b22..71519c66b3 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -3919,7 +3919,7 @@ one_more_pdu: */ length = length_remaining; if (length > msg_len) length = msg_len; - msg_tvb = tvb_new_subset(tvb, offset, length, msg_len); + msg_tvb = tvb_new_subset_length_caplen(tvb, offset, length, msg_len); /* * Now dissect the LDAP message. @@ -4108,7 +4108,7 @@ static void */ length = length_remaining; if (length > sasl_msg_len) length = sasl_msg_len; - sasl_tvb = tvb_new_subset(tvb, offset, length, sasl_msg_len); + sasl_tvb = tvb_new_subset_length_caplen(tvb, offset, length, sasl_msg_len); proto_tree_add_uint(ldap_tree, hf_ldap_sasl_buffer_length, sasl_tvb, 0, 4, sasl_len); @@ -4134,7 +4134,7 @@ static void tmp_length = tvb_reported_length_remaining(sasl_tvb, 4); if ((guint)tmp_length > sasl_len) tmp_length = sasl_len; - gssapi_tvb = tvb_new_subset(sasl_tvb, 4, tmp_length, sasl_len); + gssapi_tvb = tvb_new_subset_length_caplen(sasl_tvb, 4, tmp_length, sasl_len); /* Attempt decryption of the GSSAPI wrapped data if possible */ gssapi_encrypt.gssapi_data_encrypted = FALSE; diff --git a/epan/dissectors/packet-ldp.c b/epan/dissectors/packet-ldp.c index 544025e93f..d5df770dad 100644 --- a/epan/dissectors/packet-ldp.c +++ b/epan/dissectors/packet-ldp.c @@ -3199,7 +3199,7 @@ dissect_ldp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data length = length_remaining; if (length > plen + 4) length = plen + 4; - next_tvb = tvb_new_subset(tvb, offset, length, plen + 4); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, plen + 4); /* * Dissect the LDP packet. diff --git a/epan/dissectors/packet-ltp.c b/epan/dissectors/packet-ltp.c index 3b4c88ff17..ca78606b3c 100644 --- a/epan/dissectors/packet-ltp.c +++ b/epan/dissectors/packet-ltp.c @@ -404,7 +404,7 @@ dissect_data_segment(proto_tree *ltp_tree, tvbuff_t *tvb,packet_info *pinfo,int } } - datatvb = tvb_new_subset(new_tvb, parse_offset, (int)parse_length - parse_offset, tvb_captured_length(new_tvb)); + datatvb = tvb_new_subset_length_caplen(new_tvb, parse_offset, (int)parse_length - parse_offset, tvb_captured_length(new_tvb)); bundle_size = call_dissector(bundle_handle, datatvb, pinfo, ltp_data_data_tree); if(bundle_size == 0) { /*Couldn't parse bundle*/ col_set_str(pinfo->cinfo, COL_INFO, "Dissection Failed"); diff --git a/epan/dissectors/packet-mbtcp.c b/epan/dissectors/packet-mbtcp.c index 178ae4f418..df97f6b26d 100644 --- a/epan/dissectors/packet-mbtcp.c +++ b/epan/dissectors/packet-mbtcp.c @@ -873,7 +873,7 @@ dissect_modbus_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 } /* Build a new tvb containing just the data payload */ - next_tvb = tvb_new_subset(tvb, payload_start, payload_len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, payload_start, payload_len, reported_len); switch ( function_code ) { diff --git a/epan/dissectors/packet-meta.c b/epan/dissectors/packet-meta.c index 197af34077..c652e955a3 100644 --- a/epan/dissectors/packet-meta.c +++ b/epan/dissectors/packet-meta.c @@ -595,7 +595,7 @@ dissect_meta(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ break; case META_PROTO_DXT_HDLC: next_dissector = mtp2_handle; - next_tvb = tvb_new_subset(tvb, item_len + META_HEADER_SIZE, + next_tvb = tvb_new_subset_length_caplen(tvb, item_len + META_HEADER_SIZE, tvb_reported_length(tvb)-item_len-META_HEADER_SIZE-2, -1); break; default: diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c index 0ca7e29731..87d877f111 100644 --- a/epan/dissectors/packet-mgcp.c +++ b/epan/dissectors/packet-mgcp.c @@ -474,7 +474,7 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi sectionlen = tvb_find_dot_line(tvb, tvb_sectionbegin, -1, &tvb_sectionend); if (sectionlen != -1) { - dissect_mgcp_message(tvb_new_subset(tvb, tvb_sectionbegin, + dissect_mgcp_message(tvb_new_subset_length_caplen(tvb, tvb_sectionbegin, sectionlen, sectionlen), pinfo, tree, mgcp_tree, ti); tvb_sectionbegin = tvb_sectionend; @@ -577,7 +577,7 @@ static void dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * sectionlen = tvb_find_line_end(tvb, 0, -1, &tvb_sectionend, FALSE); if (sectionlen > 0) { - dissect_mgcp_firstline(tvb_new_subset(tvb, tvb_sectionbegin, + dissect_mgcp_firstline(tvb_new_subset_length_caplen(tvb, tvb_sectionbegin, sectionlen, sectionlen), pinfo, mgcp_tree, mi); } @@ -590,7 +590,7 @@ static void dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * &tvb_sectionend); if (sectionlen > 0) { - dissect_mgcp_params(tvb_new_subset(tvb, tvb_sectionbegin, sectionlen, sectionlen), + dissect_mgcp_params(tvb_new_subset_length_caplen(tvb, tvb_sectionbegin, sectionlen, sectionlen), mgcp_tree, mi); } } diff --git a/epan/dissectors/packet-mpeg-pes.c b/epan/dissectors/packet-mpeg-pes.c index 61c03fe35e..548421648f 100644 --- a/epan/dissectors/packet-mpeg-pes.c +++ b/epan/dissectors/packet-mpeg-pes.c @@ -937,7 +937,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data return TRUE; } - es = tvb_new_subset(tvb, offset / 8, -1, length); + es = tvb_new_subset_length_caplen(tvb, offset / 8, -1, length); if (tvb_get_ntoh24(es, 0) == PES_PREFIX) dissect_mpeg_pes(es, pinfo, tree, NULL); else if (tvb_get_guint8(es, 0) == 0xff) diff --git a/epan/dissectors/packet-msdp.c b/epan/dissectors/packet-msdp.c index b28fef8f3d..3304a2eaf0 100644 --- a/epan/dissectors/packet-msdp.c +++ b/epan/dissectors/packet-msdp.c @@ -311,7 +311,7 @@ static void dissect_msdp_sa(tvbuff_t *tvb, packet_info *pinfo, if (reported_length > length) reported_length = length; - next_tvb = tvb_new_subset(tvb, *offset, available_length, + next_tvb = tvb_new_subset_length_caplen(tvb, *offset, available_length, reported_length); /* Set the information columns read-only so that they * reflect the MSDP packet rather than the diff --git a/epan/dissectors/packet-mstp.c b/epan/dissectors/packet-mstp.c index eafe3d097d..6a21eb39a5 100644 --- a/epan/dissectors/packet-mstp.c +++ b/epan/dissectors/packet-mstp.c @@ -253,7 +253,7 @@ dissect_mstp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset, 2, ENC_BIG_ENDIAN); /* NPDU - call the Vendor specific dissector */ - next_tvb = tvb_new_subset(tvb, offset+2, + next_tvb = tvb_new_subset_length_caplen(tvb, offset+2, mstp_tvb_pdu_len-2, mstp_frame_pdu_len); } diff --git a/epan/dissectors/packet-mtp2.c b/epan/dissectors/packet-mtp2.c index b8081a658e..d802611835 100644 --- a/epan/dissectors/packet-mtp2.c +++ b/epan/dissectors/packet-mtp2.c @@ -175,7 +175,7 @@ mtp2_decode_crc16(tvbuff_t *tvb, proto_tree *fh_tree, packet_info *pinfo) reported_len -= 2; if (len > reported_len) len = reported_len; - next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, proto_offset, len, reported_len); } else { /* * We have the entire packet, and it includes a 2-byte FCS. @@ -183,7 +183,7 @@ mtp2_decode_crc16(tvbuff_t *tvb, proto_tree *fh_tree, packet_info *pinfo) */ len -= 2; reported_len -= 2; - next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, proto_offset, len, reported_len); /* * Compute the FCS and put it into the tree. diff --git a/epan/dissectors/packet-nas_eps.c b/epan/dissectors/packet-nas_eps.c index ea21458e5d..09ded5c0d0 100644 --- a/epan/dissectors/packet-nas_eps.c +++ b/epan/dissectors/packet-nas_eps.c @@ -3175,7 +3175,7 @@ de_esm_user_data_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, it = proto_tree_add_item(tree, hf_nas_eps_esm_user_data_cont, tvb, offset, len, ENC_NA); if (g_nas_eps_user_data_container_as_ip) { subtree = proto_item_add_subtree(it, ett_nas_eps_esm_user_data_cont); - user_data_cont_tvb = tvb_new_subset(tvb, offset, len, len); + user_data_cont_tvb = tvb_new_subset_length_caplen(tvb, offset, len, len); switch (tvb_get_guint8(user_data_cont_tvb, 0) & 0xf0) { case 0x40: col_append_str(pinfo->cinfo, COL_PROTOCOL, "/"); diff --git a/epan/dissectors/packet-nb_rtpmux.c b/epan/dissectors/packet-nb_rtpmux.c index a68975f532..d492a08362 100644 --- a/epan/dissectors/packet-nb_rtpmux.c +++ b/epan/dissectors/packet-nb_rtpmux.c @@ -149,7 +149,7 @@ dissect_nb_rtpmux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat captured_length = tvb_reported_length_remaining(tvb, offset + 5); if (captured_length > (gint)length) captured_length = length; - next_tvb = tvb_new_subset(tvb, offset+5, captured_length, + next_tvb = tvb_new_subset_length_caplen(tvb, offset+5, captured_length, length); if (first_rtp_payload_seen) diff --git a/epan/dissectors/packet-nbt.c b/epan/dissectors/packet-nbt.c index b9efc67bfb..ab8342dd29 100644 --- a/epan/dissectors/packet-nbt.c +++ b/epan/dissectors/packet-nbt.c @@ -1684,7 +1684,7 @@ dissect_nbss(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) length = length_remaining; if (length > plen) length = plen; - next_tvb = tvb_new_subset(tvb, offset, length, plen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, plen); dissect_nbss_packet(next_tvb, pinfo, tree, is_cifs); diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index 6be77b86de..67aadbdfda 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -1263,7 +1263,7 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } else { /* * XXX - do this by using -1 and -1 as the length - * arguments to "tvb_new_subset()" and then calling + * arguments to "tvb_new_subset_length_caplen()" and then calling * "tvb_set_reported_length()"? That'll throw an * exception if "data_len" goes past the reported * length of the packet, but that's arguably a @@ -1273,7 +1273,7 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (length_remaining > data_len) length_remaining = data_len; if (data_len != 0) { - call_data_dissector(tvb_new_subset(tvb, offset, + call_data_dissector(tvb_new_subset_length_caplen(tvb, offset, length_remaining, data_len), pinfo, ncp_tree); } diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc index 63b1754ba4..31a66582fa 100644 --- a/epan/dissectors/packet-ncp2222.inc +++ b/epan/dissectors/packet-ncp2222.inc @@ -6949,7 +6949,7 @@ nds_defrag(tvbuff_t *tvb, packet_info *pinfo, guint32 nw_connection, guint8 sequ else { /* This is either a beggining or middle fragment on second dissection */ - frag_tvb = tvb_new_subset(tvb, 0, -1, -1); + frag_tvb = tvb_new_subset_length_caplen(tvb, 0, -1, -1); if (request_value->nds_frag) { col_add_fstr(pinfo->cinfo, COL_INFO, "[NDS Fragment 0x%08x]", frags[frag_count].nds_frag); @@ -6972,12 +6972,12 @@ nds_defrag(tvbuff_t *tvb, packet_info *pinfo, guint32 nw_connection, guint8 sequ /* * There are no bytes so Dissect this */ - frag_tvb = tvb_new_subset(tvb, 0, -1, -1); + frag_tvb = tvb_new_subset_length_caplen(tvb, 0, -1, -1); } if (frag_tvb == NULL) { /* This is a fragment packet */ - frag_tvb = tvb_new_subset (tvb, 0, -1, -1); + frag_tvb = tvb_new_subset_length_caplen(tvb, 0, -1, -1); nds_data_handle = find_dissector("data"); call_dissector(nds_data_handle, frag_tvb, pinfo, tree); } diff --git a/epan/dissectors/packet-ndmp.c b/epan/dissectors/packet-ndmp.c index f8d0f8f5ed..9fab54f7ec 100644 --- a/epan/dissectors/packet-ndmp.c +++ b/epan/dissectors/packet-ndmp.c @@ -1364,7 +1364,7 @@ dissect_execute_cdb_cdb(tvbuff_t *tvb, int offset, packet_info *pinfo, tvb_rlen=tvb_reported_length_remaining(tvb, offset); if(tvb_rlen>16) tvb_rlen=16; - cdb_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen); + cdb_tvb=tvb_new_subset_length_caplen(tvb, offset, tvb_len, tvb_rlen); if(ndmp_conv_data->task && !ndmp_conv_data->task->itlq){ ndmp_conv_data->task->itlq=wmem_new(wmem_file_scope(), itlq_nexus_t); @@ -1417,7 +1417,7 @@ dissect_execute_cdb_payload(tvbuff_t *tvb, int offset, packet_info *pinfo, proto tvb_rlen=tvb_reported_length_remaining(tvb, offset); if(tvb_rlen>(int)payload_len) tvb_rlen=payload_len; - data_tvb=tvb_new_subset(tvb, offset, tvb_len, tvb_rlen); + data_tvb=tvb_new_subset_length_caplen(tvb, offset, tvb_len, tvb_rlen); if(ndmp_conv_data->task && ndmp_conv_data->task->itlq){ /* ndmp conceptually always send both read and write diff --git a/epan/dissectors/packet-negoex.c b/epan/dissectors/packet-negoex.c index 8632846f8e..3027ca20f4 100644 --- a/epan/dissectors/packet-negoex.c +++ b/epan/dissectors/packet-negoex.c @@ -448,7 +448,7 @@ dissect_negoex(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _ * Construct a new TVB covering just this message and pass to the * sub-dissector */ - msg_tvb = tvb_new_subset(tvb, + msg_tvb = tvb_new_subset_length_caplen(tvb, start_offset, MIN(message_len, tvb_captured_length(tvb)), message_len); diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c index 837c63481a..6d1dd3b095 100644 --- a/epan/dissectors/packet-nfs.c +++ b/epan/dissectors/packet-nfs.c @@ -2258,7 +2258,7 @@ dissect_fhandle_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree * /* Functionality for choosing subdissector is controlled through Decode As as NFS doesn't have a unique identifier to determine subdissector */ - fh_tvb = tvb_new_subset(tvb, offset, fhlen, fhlen); + fh_tvb = tvb_new_subset_length_caplen(tvb, offset, fhlen, fhlen); if (!dissector_try_uint(nfs_fhandle_table, 0, fh_tvb, pinfo, tree)) dissect_fhandle_data_unknown(fh_tvb, pinfo, tree, NULL); } diff --git a/epan/dissectors/packet-nordic_ble.c b/epan/dissectors/packet-nordic_ble.c index f2f924c945..9378fc5fbd 100644 --- a/epan/dissectors/packet-nordic_ble.c +++ b/epan/dissectors/packet-nordic_ble.c @@ -307,7 +307,7 @@ dissect_nordic_ble(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da context = wmem_new0(wmem_packet_scope(), btle_context_t); offset = dissect_header(tvb, pinfo, tree, context, &bad_length); - payload_tvb = tvb_new_subset(tvb, offset, -1, tvb_captured_length(tvb) - offset); + payload_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, tvb_captured_length(tvb) - offset); if (!bad_length) { call_dissector_with_data(btle_dissector_handle, payload_tvb, pinfo, tree, context); diff --git a/epan/dissectors/packet-nsip.c b/epan/dissectors/packet-nsip.c index c43386e478..bda4dc2d12 100644 --- a/epan/dissectors/packet-nsip.c +++ b/epan/dissectors/packet-nsip.c @@ -344,7 +344,7 @@ decode_iei_ns_pdu(nsip_ie_t *ie, build_info_t *bi, int ie_start_offset) { proto_tree_add_bytes_format(bi->nsip_tree, hf_nsip_ns_pdu, bi->tvb, ie_start_offset, ie->total_length, NULL, "NS PDU (%u bytes)", ie->value_length); - next_tvb = tvb_new_subset(bi->tvb, bi->offset, ie->value_length, -1); + next_tvb = tvb_new_subset_length_caplen(bi->tvb, bi->offset, ie->value_length, -1); if (nsip_handle) { gboolean was_recursive; was_recursive = nsip_is_recursive; diff --git a/epan/dissectors/packet-opa.c b/epan/dissectors/packet-opa.c index 4b4c71eb80..0c32d3326b 100644 --- a/epan/dissectors/packet-opa.c +++ b/epan/dissectors/packet-opa.c @@ -1280,7 +1280,7 @@ static int dissect_opa_9b(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v captured_length = reported_length; if (captured_length > 0) { - opa_tvb = tvb_new_subset(tvb, offset, captured_length, reported_length); + opa_tvb = tvb_new_subset_length_caplen(tvb, offset, captured_length, reported_length); call_dissector(opa_mad_handle, opa_tvb, pinfo, tree); offset += captured_length; } diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c index d3162cdc8b..e60972d47f 100644 --- a/epan/dissectors/packet-opensafety.c +++ b/epan/dissectors/packet-opensafety.c @@ -741,7 +741,7 @@ dissect_data_payload ( proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, if (len > 0) { - payload_tvb = tvb_new_subset(tvb, off, len, tvb_reported_length_remaining(tvb, offset) ); + payload_tvb = tvb_new_subset_length_caplen(tvb, off, len, tvb_reported_length_remaining(tvb, offset) ); if ( ! dissector_try_heuristic(heur_opensafety_spdo_subdissector_list, payload_tvb, pinfo, epl_tree, &hdtbl_entry, &msgType)) call_dissector(data_dissector, payload_tvb, pinfo, epl_tree); @@ -2163,14 +2163,14 @@ opensafety_package_dissector(const gchar *protocolName, const gchar *sub_diss_ha if ( global_display_intergap_data == TRUE && gapStart != frameOffset ) { /* Storing the gap data in subset, and calling the data dissector to display it */ - gap_tvb = tvb_new_subset(message_tvb, gapStart, (frameOffset - gapStart), reported_len); + gap_tvb = tvb_new_subset_length_caplen(message_tvb, gapStart, (frameOffset - gapStart), reported_len); call_dissector(data_dissector, gap_tvb, pinfo, tree); } /* Setting the gap to the next offset */ gapStart = frameOffset + frameLength; /* Adding second data source */ - next_tvb = tvb_new_subset ( message_tvb, frameOffset, frameLength, reported_len ); + next_tvb = tvb_new_subset_length_caplen ( message_tvb, frameOffset, frameLength, reported_len ); /* Adding a visual aid to the dissector tree */ add_new_data_source(pinfo, next_tvb, "openSAFETY Frame"); @@ -2256,7 +2256,7 @@ opensafety_package_dissector(const gchar *protocolName, const gchar *sub_diss_ha if ( frameOffset < length && global_display_intergap_data == TRUE && gapStart != frameOffset ) { /* Storing the gap data in subset, and calling the data dissector to display it */ - gap_tvb = tvb_new_subset(message_tvb, gapStart, (length - gapStart), reported_len); + gap_tvb = tvb_new_subset_length_caplen(message_tvb, gapStart, (length - gapStart), reported_len); call_dissector(data_dissector, gap_tvb, pinfo, tree); } } diff --git a/epan/dissectors/packet-pana.c b/epan/dissectors/packet-pana.c index 299230737f..cbd673bdc5 100644 --- a/epan/dissectors/packet-pana.c +++ b/epan/dissectors/packet-pana.c @@ -374,7 +374,7 @@ dissect_avps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *avp_tree) avp_group_tree = proto_tree_add_subtree(single_avp_tree, tvb, offset, avp_data_length, ett_pana_avp, NULL, "Grouped AVP"); - group_tvb = tvb_new_subset(tvb, offset, + group_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(avp_data_length, tvb_reported_length(tvb)-offset), avp_data_length); dissect_avps(group_tvb, pinfo, avp_group_tree); diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c index d819a23c4b..b61f4a356f 100644 --- a/epan/dissectors/packet-ppi.c +++ b/epan/dissectors/packet-ppi.c @@ -944,7 +944,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) else /* we found a suitable dissector */ { /* skip over the ppi_fieldheader, and pass it off to the dedicated GPS dissetor */ - next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1); call_dissector(ppi_gps_handle, next_tvb, pinfo, ppi_tree); } break; @@ -957,7 +957,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) else /* we found a suitable dissector */ { /* skip over the ppi_fieldheader, and pass it off to the dedicated VECTOR dissetor */ - next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1); call_dissector(ppi_vector_handle, next_tvb, pinfo, ppi_tree); } break; @@ -970,7 +970,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) else /* we found a suitable dissector */ { /* skip over the ppi_fieldheader, and pass it off to the dedicated SENSOR dissetor */ - next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1); call_dissector(ppi_sensor_handle, next_tvb, pinfo, ppi_tree); } break; @@ -983,7 +983,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) else /* we found a suitable dissector */ { /* skip over the ppi_fieldheader, and pass it off to the dedicated ANTENNA dissetor */ - next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1); call_dissector(ppi_antenna_handle, next_tvb, pinfo, ppi_tree); } break; @@ -996,7 +996,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) else /* we found a suitable dissector */ { /* skip over the ppi_fieldheader, and pass it off to the dedicated FNET dissetor */ - next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1); call_dissector(ppi_fnet_handle, next_tvb, pinfo, ppi_tree); } break; diff --git a/epan/dissectors/packet-ppp.c b/epan/dissectors/packet-ppp.c index 318415cbb8..b542c7a686 100644 --- a/epan/dissectors/packet-ppp.c +++ b/epan/dissectors/packet-ppp.c @@ -1910,7 +1910,7 @@ decode_fcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *fh_tree, int fcs_decod reported_len -= 2; if (len > reported_len) len = reported_len; - next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, proto_offset, len, reported_len); } else { /* * We have the entire packet, and it includes a 2-byte FCS. @@ -1918,7 +1918,7 @@ decode_fcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *fh_tree, int fcs_decod */ len -= 2; reported_len -= 2; - next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, proto_offset, len, reported_len); /* * Compute the FCS and put it into the tree. @@ -1952,7 +1952,7 @@ decode_fcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *fh_tree, int fcs_decod reported_len -= 4; if (len > reported_len) len = reported_len; - next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, proto_offset, len, reported_len); } else { /* * We have the entire packet, and it includes a 4-byte FCS. @@ -1960,7 +1960,7 @@ decode_fcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *fh_tree, int fcs_decod */ len -= 4; reported_len -= 4; - next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, proto_offset, len, reported_len); /* * Compute the FCS and put it into the tree. @@ -4574,7 +4574,7 @@ dissect_bcp_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data reported_length -= pad_length; if (captured_length > reported_length) captured_length = reported_length; - next_tvb = tvb_new_subset(tvb, offset, captured_length, + next_tvb = tvb_new_subset_length_caplen(tvb, offset, captured_length, reported_length); switch (mac_type) { diff --git a/epan/dissectors/packet-pppoe.c b/epan/dissectors/packet-pppoe.c index 05081dd9e5..46fc3c8cd3 100644 --- a/epan/dissectors/packet-pppoe.c +++ b/epan/dissectors/packet-pppoe.c @@ -1182,7 +1182,7 @@ static int dissect_pppoes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v length = reported_payload_length; if ((guint)reported_length > reported_payload_length) reported_length = reported_payload_length; - next_tvb = tvb_new_subset(tvb,(6 + credit_offset), + next_tvb = tvb_new_subset_length_caplen(tvb,(6 + credit_offset), (length - credit_offset), (reported_length - credit_offset)); call_dissector(ppp_handle,next_tvb,pinfo,tree); diff --git a/epan/dissectors/packet-pw-atm.c b/epan/dissectors/packet-pw-atm.c index 609c1e7112..6a25be182d 100644 --- a/epan/dissectors/packet-pw-atm.c +++ b/epan/dissectors/packet-pw-atm.c @@ -428,7 +428,7 @@ dissect_payload_and_padding( bytes_to_dissect = SIZEOF_ATM_CELL_PAYLOAD; else bytes_to_dissect = (payload_size - dissected); - tvb_3 = tvb_new_subset(tvb_2, 0, bytes_to_dissect, -1); + tvb_3 = tvb_new_subset_length_caplen(tvb_2, 0, bytes_to_dissect, -1); /*aal5_sdu: disable filling columns after 1st (valid) oam cell*/ if (pd->mode == PWATM_MODE_AAL5_SDU && (pd->pw_cell_number > 0)) { @@ -872,7 +872,7 @@ dissect_aal5_sdu(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* d if (padding_size != 0) { tvbuff_t* tvb_3; - tvb_3 = tvb_new_subset(tvb_2, payload_size, padding_size, -1); + tvb_3 = tvb_new_subset_length_caplen(tvb_2, payload_size, padding_size, -1); call_dissector(dh_padding, tvb_3, pinfo, tree); } } @@ -1613,7 +1613,7 @@ dissect_cell(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * data proto_tree* tree2; tvbuff_t* tvb_d; tree2 = proto_item_add_subtree(item, ett_cell); - tvb_d = tvb_new_subset(tvb, 0, dissect_size, -1); + tvb_d = tvb_new_subset_length_caplen(tvb, 0, dissect_size, -1); call_data_dissector(tvb_d, pinfo, tree2); item = proto_tree_add_int(tree2, hf_cell_payload_len, tvb, 0, 0, dissect_size); PROTO_ITEM_SET_HIDDEN(item); diff --git a/epan/dissectors/packet-pw-cesopsn.c b/epan/dissectors/packet-pw-cesopsn.c index 76c7ec50b7..474b1bcd11 100644 --- a/epan/dissectors/packet-pw-cesopsn.c +++ b/epan/dissectors/packet-pw-cesopsn.c @@ -361,7 +361,7 @@ void dissect_pw_cesopsn( tvbuff_t * tvb_original tree2 = proto_item_add_subtree(item, ett); { tvbuff_t* tvb; - tvb = tvb_new_subset(tvb_original, PWC_SIZEOF_CW + payload_size, padding_size, -1); + tvb = tvb_new_subset_length_caplen(tvb_original, PWC_SIZEOF_CW + payload_size, padding_size, -1); call_dissector(pw_padding_handle, tvb, pinfo, tree2); } } diff --git a/epan/dissectors/packet-pw-satop.c b/epan/dissectors/packet-pw-satop.c index 821d8a748b..19c1a6192a 100644 --- a/epan/dissectors/packet-pw-satop.c +++ b/epan/dissectors/packet-pw-satop.c @@ -375,7 +375,7 @@ void dissect_pw_satop(tvbuff_t * tvb_original tree2 = proto_item_add_subtree(item, ett); { tvbuff_t* tvb; - tvb = tvb_new_subset(tvb_original, PWC_SIZEOF_CW + payload_size, padding_size, -1); + tvb = tvb_new_subset_length_caplen(tvb_original, PWC_SIZEOF_CW + payload_size, padding_size, -1); call_dissector(pw_padding_handle, tvb, pinfo, tree2); } } diff --git a/epan/dissectors/packet-q932-ros.c b/epan/dissectors/packet-q932-ros.c index d2fc2a2d92..37c4f8dbe5 100644 --- a/epan/dissectors/packet-q932-ros.c +++ b/epan/dissectors/packet-q932-ros.c @@ -307,7 +307,7 @@ dissect_q932_ros_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size); if (!arg_next_tvb) { /* empty argument */ - arg_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + arg_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((arg_handle)?arg_handle:data_handle, arg_next_tvb, actx->pinfo, tree, actx->rose_ctx); @@ -401,7 +401,7 @@ dissect_q932_ros_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int if (actx->rose_ctx->d.code != -1) { if (!res_next_tvb) { /* empty result */ - res_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + res_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((res_handle)?res_handle:data_handle, res_next_tvb, actx->pinfo, tree, actx->rose_ctx); @@ -480,7 +480,7 @@ dissect_q932_ros_ReturnError(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o g_strlcat(actx->rose_ctx->fillin_ptr, descr, actx->rose_ctx->fillin_buf_size); if (!err_next_tvb) { /* empty error */ - err_next_tvb = tvb_new_subset(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); + err_next_tvb = tvb_new_subset_length_caplen(tvb, (actx->encoding==ASN1_ENC_PER)?offset>>3:offset, 0, 0); } call_dissector_with_data((err_handle)?err_handle:data_handle, err_next_tvb, actx->pinfo, tree, actx->rose_ctx); diff --git a/epan/dissectors/packet-reload-framing.c b/epan/dissectors/packet-reload-framing.c index 42de6f4311..d5eef8749e 100644 --- a/epan/dissectors/packet-reload-framing.c +++ b/epan/dissectors/packet-reload-framing.c @@ -343,7 +343,7 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr proto_tree_add_item(message_tree, hf_reload_framing_message_length, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; proto_tree_add_item(message_tree, hf_reload_framing_message_data, tvb, offset, message_length, ENC_NA); - next_tvb = tvb_new_subset(tvb, offset, effective_length - offset, message_length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, effective_length - offset, message_length); if (reload_handle == NULL) { expert_add_info(pinfo, ti, &ei_reload_no_dissector); return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-reload.c b/epan/dissectors/packet-reload.c index 0ce7c0f6b8..6f7e13f943 100644 --- a/epan/dissectors/packet-reload.c +++ b/epan/dissectors/packet-reload.c @@ -3596,7 +3596,7 @@ extern gint dissect_reload_messagecontents(tvbuff_t *tvb, packet_info *pinfo, pr config_data_tree = proto_item_add_subtree(ti_config_data, ett_reload_configupdatereq_config_data); proto_tree_add_item(config_data_tree, hf_reload_length_uint24, tvb, offset+local_offset, 3, ENC_BIG_ENDIAN); call_dissector_only(xml_handle, - tvb_new_subset(tvb, offset+local_offset+3, config_length, length-offset-local_offset-3), + tvb_new_subset_length_caplen(tvb, offset+local_offset+3, config_length, length-offset-local_offset-3), pinfo, config_data_tree, NULL); } } @@ -3633,7 +3633,7 @@ extern gint dissect_reload_messagecontents(tvbuff_t *tvb, packet_info *pinfo, pr proto_tree_add_item(kinddescription_tree, hf_reload_length_uint16, tvb, offset+local_offset+kinds_offset, 2, ENC_BIG_ENDIAN); call_dissector(xml_handle, - tvb_new_subset(tvb, offset+local_offset+kinds_offset+2, + tvb_new_subset_length_caplen(tvb, offset+local_offset+kinds_offset+2, local_increment, length-(offset+local_offset+kinds_offset+2)), pinfo, kinddescription_tree); diff --git a/epan/dissectors/packet-rftap.c b/epan/dissectors/packet-rftap.c index 901c24f672..8336714419 100644 --- a/epan/dissectors/packet-rftap.c +++ b/epan/dissectors/packet-rftap.c @@ -316,7 +316,7 @@ dissect_rftap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, /* dissect part 1: rftap header */ rftap_len = 4 * (gint32) tvb_get_letohs(tvb, 4); - rftap_tvb = tvb_new_subset(tvb, 0, rftap_len, rftap_len); + rftap_tvb = tvb_new_subset_length_caplen(tvb, 0, rftap_len, rftap_len); ti = proto_tree_add_protocol_format(tree, proto_rftap, rftap_tvb, 0, -1, "RFtap Protocol (%d bytes)", rftap_len); diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index db73e08f57..6c8f7359c3 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -779,7 +779,7 @@ dissect_rpc_opaque_data(tvbuff_t *tvb, int offset, if (dissect_it) { tvbuff_t *opaque_tvb; - opaque_tvb = tvb_new_subset(tvb, data_offset, string_length_copy, + opaque_tvb = tvb_new_subset_length_caplen(tvb, data_offset, string_length_copy, string_length); return (*dissect_it)(opaque_tvb, offset, pinfo, tree, NULL); @@ -1362,7 +1362,7 @@ dissect_rpc_authgss_token(tvbuff_t* tvb, proto_tree* tree, int offset, length = opaque_length; if ((guint32)reported_length > opaque_length) reported_length = opaque_length; - new_tvb = tvb_new_subset(tvb, offset, length, reported_length); + new_tvb = tvb_new_subset_length_caplen(tvb, offset, length, reported_length); len_consumed = call_dissector(gssapi_handle, new_tvb, pinfo, gtree); offset += len_consumed; } @@ -3359,7 +3359,7 @@ dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo, tvb_len = len; if (tvb_reported_len > (gint)len) tvb_reported_len = len; - frag_tvb = tvb_new_subset(tvb, offset, tvb_len, + frag_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_len, tvb_reported_len); /* diff --git a/epan/dissectors/packet-rpcap.c b/epan/dissectors/packet-rpcap.c index da428e5683..eb0ebb03be 100644 --- a/epan/dissectors/packet-rpcap.c +++ b/epan/dissectors/packet-rpcap.c @@ -874,7 +874,7 @@ dissect_rpcap_packet (tvbuff_t *tvb, packet_info *pinfo, proto_tree *top_tree, return; } - new_tvb = tvb_new_subset (tvb, offset, caplen, len); + new_tvb = tvb_new_subset_length_caplen (tvb, offset, caplen, len); if (decode_content && linktype != -1) { TRY { call_dissector_with_data(pcap_pktdata_handle, new_tvb, pinfo, top_tree, &linktype); diff --git a/epan/dissectors/packet-rpl.c b/epan/dissectors/packet-rpl.c index ec8e568f66..4aafe38b24 100644 --- a/epan/dissectors/packet-rpl.c +++ b/epan/dissectors/packet-rpl.c @@ -146,7 +146,7 @@ dissect_rpl_container(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (reported_length > sublen) reported_length = sublen; if ( length > 0) { - dissect_rpl_container(tvb_new_subset(tvb, + dissect_rpl_container(tvb_new_subset_length_caplen(tvb, offset, length, reported_length), pinfo, rpl_container_tree); offset += reported_length; diff --git a/epan/dissectors/packet-rsvd.c b/epan/dissectors/packet-rsvd.c index c64a1a7533..64507234b1 100644 --- a/epan/dissectors/packet-rsvd.c +++ b/epan/dissectors/packet-rsvd.c @@ -258,7 +258,7 @@ dissect_RSVD_TUNNEL_SCSI(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pare offset += 4; /* CDBBuffer */ - scsi_cdb = tvb_new_subset(tvb, + scsi_cdb = tvb_new_subset_length_caplen(tvb, offset, cdb_length, tvb_reported_length_remaining(tvb, offset)); @@ -359,7 +359,7 @@ dissect_RSVD_TUNNEL_SCSI(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pare if (tvb_rlen > (int)data_transfer_length) tvb_rlen = data_transfer_length; - data_tvb = tvb_new_subset(tvb, offset, tvb_len, tvb_rlen); + data_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_len, tvb_rlen); if (rsvd_conv_data->task && rsvd_conv_data->task->itlq) { rsvd_conv_data->task->itlq->task_flags = SCSI_DATA_READ | diff --git a/epan/dissectors/packet-rtp.c b/epan/dissectors/packet-rtp.c index ee49751cc6..640ef2a24e 100644 --- a/epan/dissectors/packet-rtp.c +++ b/epan/dissectors/packet-rtp.c @@ -1585,7 +1585,7 @@ dissect_rtp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if(finfo == NULL || !desegment_rtp) { /* Hand the whole lot off to the subdissector */ - newtvb = tvb_new_subset(tvb, offset, data_len, data_reported_len); + newtvb = tvb_new_subset_length_caplen(tvb, offset, data_len, data_reported_len); process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type); return; } @@ -1672,7 +1672,7 @@ dissect_rtp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, #ifdef DEBUG_FRAGMENTS g_debug("\tRTP non-fragment payload"); #endif - newtvb = tvb_new_subset( tvb, offset, data_len, data_reported_len ); + newtvb = tvb_new_subset_length_caplen( tvb, offset, data_len, data_reported_len ); /* Hand off to the subdissector */ process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type); diff --git a/epan/dissectors/packet-rtsp.c b/epan/dissectors/packet-rtsp.c index f5744d971b..8a4c167f7c 100644 --- a/epan/dissectors/packet-rtsp.c +++ b/epan/dissectors/packet-rtsp.c @@ -388,7 +388,7 @@ dissect_rtspinterleaved(tvbuff_t *tvb, int offset, packet_info *pinfo, */ if (length_remaining > rf_len) length_remaining = rf_len; - next_tvb = tvb_new_subset(tvb, offset, length_remaining, rf_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length_remaining, rf_len); conv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); @@ -1324,7 +1324,7 @@ dissect_rtspmessage(tvbuff_t *tvb, int offset, packet_info *pinfo, * which, if no content length was specified, * is -1, i.e. "to the end of the frame. */ - new_tvb = tvb_new_subset(tvb, offset, datalen, + new_tvb = tvb_new_subset_length_caplen(tvb, offset, datalen, reported_datalen); if (media_type_str_lower_case && diff --git a/epan/dissectors/packet-s5066sis.c b/epan/dissectors/packet-s5066sis.c index e1cfe3d1f6..ed7902223c 100644 --- a/epan/dissectors/packet-s5066sis.c +++ b/epan/dissectors/packet-s5066sis.c @@ -1049,7 +1049,7 @@ dissect_s5066_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* reported_length = pdu_size - offset; available_length = tvb_captured_length(tvb) - offset; - next_tvb = tvb_new_subset(tvb, offset, MIN(available_length, reported_length), reported_length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(available_length, reported_length), reported_length); if(dissector_try_uint(s5066sis_dissector_table, client_app_id, next_tvb, pinfo, tree) == 0) { call_data_dissector(next_tvb, pinfo, tree); diff --git a/epan/dissectors/packet-scsi.c b/epan/dissectors/packet-scsi.c index 0a582cb511..1a790efad7 100644 --- a/epan/dissectors/packet-scsi.c +++ b/epan/dissectors/packet-scsi.c @@ -3848,7 +3848,7 @@ dissect_scsi_log_page(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, if (log_parameter && log_parameter->dissector) { tvbuff_t *param_tvb; - param_tvb = tvb_new_subset(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),paramlen), paramlen); + param_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),paramlen), paramlen); log_parameter->dissector(param_tvb, pinfo, log_tree); } else { /* We did not have a dissector for this page/parameter so @@ -4644,7 +4644,7 @@ dissect_spc_modeselect6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, payload_len -= 1; if (tvb_reported_length_remaining(tvb, offset)>0) { - blockdesc_tvb = tvb_new_subset(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); + blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, FALSE); } offset += desclen; @@ -4738,7 +4738,7 @@ dissect_spc_modeselect10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, payload_len -= 2; if (tvb_reported_length_remaining(tvb, offset)>0) { - blockdesc_tvb = tvb_new_subset(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); + blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, longlba); } offset += desclen; @@ -4868,7 +4868,7 @@ dissect_spc_modesense6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (tvb_reported_length_remaining(tvb, offset)>0) { - blockdesc_tvb = tvb_new_subset(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); + blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, FALSE); } offset += desclen; @@ -4958,7 +4958,7 @@ dissect_spc_modesense10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tot_len -= 2; if (tvb_reported_length_remaining(tvb, offset)>0) { - blockdesc_tvb = tvb_new_subset(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); + blockdesc_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(tvb_reported_length_remaining(tvb, offset),desclen), desclen); dissect_scsi_blockdescs(blockdesc_tvb, pinfo, tree, cdata, longlba); } offset += desclen; diff --git a/epan/dissectors/packet-scsi.h b/epan/dissectors/packet-scsi.h index 085beae338..7da0c4b1b8 100644 --- a/epan/dissectors/packet-scsi.h +++ b/epan/dissectors/packet-scsi.h @@ -264,7 +264,7 @@ extern value_string_ext scsi_asc_val_ext; guint32 try_end_data_offset=0; \ \ try_short_packet=pinfo->fd->cap_lenfd->pkt_len; \ - try_tvb=tvb_new_subset(tvb_a, offset_a, tvb_captured_length_remaining(tvb_a, offset_a), length_arg); \ + try_tvb=tvb_new_subset_length_caplen(tvb_a, offset_a, tvb_captured_length_remaining(tvb_a, offset_a), length_arg); \ try_offset=0; \ TRY { diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c index 457ca8235b..e7cb2f7f26 100644 --- a/epan/dissectors/packet-sctp.c +++ b/epan/dissectors/packet-sctp.c @@ -1766,7 +1766,7 @@ dissect_add_ip_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, pr address_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - CORRELATION_ID_LENGTH; proto_tree_add_item(parameter_tree, hf_correlation_id, parameter_tvb, CORRELATION_ID_OFFSET, CORRELATION_ID_LENGTH, ENC_BIG_ENDIAN); - address_tvb = tvb_new_subset(parameter_tvb, ADDRESS_PARAMETER_OFFSET, + address_tvb = tvb_new_subset_length_caplen(parameter_tvb, ADDRESS_PARAMETER_OFFSET, MIN(address_length, tvb_captured_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)), MIN(address_length, tvb_reported_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET))); proto_item_append_text(parameter_item, " (Address: "); @@ -1783,7 +1783,7 @@ dissect_del_ip_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, pr address_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - CORRELATION_ID_LENGTH; proto_tree_add_item(parameter_tree, hf_correlation_id, parameter_tvb, CORRELATION_ID_OFFSET, CORRELATION_ID_LENGTH, ENC_BIG_ENDIAN); - address_tvb = tvb_new_subset(parameter_tvb, ADDRESS_PARAMETER_OFFSET, + address_tvb = tvb_new_subset_length_caplen(parameter_tvb, ADDRESS_PARAMETER_OFFSET, MIN(address_length, tvb_captured_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)), MIN(address_length, tvb_reported_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET))); proto_item_append_text(parameter_item, " (Address: "); @@ -1801,7 +1801,7 @@ dissect_error_cause_indication_parameter(tvbuff_t *parameter_tvb, packet_info *p proto_tree_add_item(parameter_tree, hf_correlation_id, parameter_tvb, CORRELATION_ID_OFFSET, CORRELATION_ID_LENGTH, ENC_BIG_ENDIAN); causes_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - CORRELATION_ID_LENGTH; - causes_tvb = tvb_new_subset(parameter_tvb, ERROR_CAUSE_IND_CASUES_OFFSET, + causes_tvb = tvb_new_subset_length_caplen(parameter_tvb, ERROR_CAUSE_IND_CASUES_OFFSET, MIN(causes_length, tvb_captured_length_remaining(parameter_tvb, ERROR_CAUSE_IND_CASUES_OFFSET)), MIN(causes_length, tvb_reported_length_remaining(parameter_tvb, ERROR_CAUSE_IND_CASUES_OFFSET))); dissect_error_causes(causes_tvb, pinfo, parameter_tree); @@ -1816,7 +1816,7 @@ dissect_set_primary_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinf address_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - CORRELATION_ID_LENGTH; proto_tree_add_item(parameter_tree, hf_correlation_id, parameter_tvb, CORRELATION_ID_OFFSET, CORRELATION_ID_LENGTH, ENC_BIG_ENDIAN); - address_tvb = tvb_new_subset(parameter_tvb, ADDRESS_PARAMETER_OFFSET, + address_tvb = tvb_new_subset_length_caplen(parameter_tvb, ADDRESS_PARAMETER_OFFSET, MIN(address_length, tvb_captured_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)), MIN(address_length, tvb_reported_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET))); proto_item_append_text(parameter_item, " (Address: "); @@ -2083,7 +2083,7 @@ dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tre total_length = MIN(total_length, remaining_length); /* create a tvb for the parameter including the padding bytes */ - parameter_tvb = tvb_new_subset(parameters_tvb, offset, MIN(total_length, tvb_captured_length_remaining(parameters_tvb, offset)), total_length); + parameter_tvb = tvb_new_subset_length_caplen(parameters_tvb, offset, MIN(total_length, tvb_captured_length_remaining(parameters_tvb, offset)), total_length); /* get rid of the handled parameter */ offset += total_length; remaining_length = tvb_reported_length_remaining(parameters_tvb, offset); @@ -2169,7 +2169,7 @@ dissect_unresolvable_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, prot tvbuff_t *parameter_tvb; parameter_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - parameter_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(parameter_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(parameter_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); proto_item_append_text(cause_item, " (Address: "); @@ -2188,7 +2188,7 @@ dissect_unrecognized_chunk_type_cause(tvbuff_t *cause_tvb, packet_info *pinfo, tvbuff_t *unrecognized_chunk_tvb; chunk_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - unrecognized_chunk_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + unrecognized_chunk_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(chunk_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(chunk_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); dissect_sctp_chunk(unrecognized_chunk_tvb, pinfo, cause_tree,cause_tree, NULL, FALSE); @@ -2209,7 +2209,7 @@ dissect_unrecognized_parameters_cause(tvbuff_t *cause_tvb, packet_info *pinfo, p cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - unrecognized_parameters_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + unrecognized_parameters_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); dissect_parameters(unrecognized_parameters_tvb, pinfo, cause_tree, NULL, FALSE); @@ -2237,7 +2237,7 @@ dissect_restart_with_new_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, tvbuff_t *parameter_tvb; cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - parameter_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); proto_item_append_text(cause_item, " (New addresses: "); @@ -2272,7 +2272,7 @@ dissect_delete_last_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto tvbuff_t *parameter_tvb; cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - parameter_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); proto_item_append_text(cause_item, " (Last address: "); @@ -2287,7 +2287,7 @@ dissect_resource_outage_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tre tvbuff_t *parameter_tvb; cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - parameter_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); dissect_parameter(parameter_tvb, pinfo, cause_tree, NULL, FALSE, FALSE); @@ -2300,7 +2300,7 @@ dissect_delete_source_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, pro tvbuff_t *parameter_tvb; cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - parameter_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); proto_item_append_text(cause_item, " (Deleted address: "); @@ -2315,7 +2315,7 @@ dissect_request_refused_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tre tvbuff_t *parameter_tvb; cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH; - parameter_tvb = tvb_new_subset(cause_tvb, CAUSE_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET, MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)), MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET))); dissect_parameter(parameter_tvb, pinfo, cause_tree, NULL, FALSE, FALSE); @@ -2480,7 +2480,7 @@ dissect_error_causes(tvbuff_t *causes_tvb, packet_info *pinfo, proto_tree *tree) total_length = MIN(total_length, remaining_length); /* create a tvb for the parameter including the padding bytes */ - cause_tvb = tvb_new_subset(causes_tvb, offset, MIN(total_length, tvb_captured_length_remaining(causes_tvb, offset)), total_length); + cause_tvb = tvb_new_subset_length_caplen(causes_tvb, offset, MIN(total_length, tvb_captured_length_remaining(causes_tvb, offset)), total_length); dissect_error_cause(cause_tvb, pinfo, tree); @@ -3406,7 +3406,7 @@ dissect_data_chunk(tvbuff_t *chunk_tvb, header_length = DATA_CHUNK_HEADER_LENGTH; payload_offset = DATA_CHUNK_PAYLOAD_OFFSET; } - payload_tvb = tvb_new_subset(chunk_tvb, payload_offset, + payload_tvb = tvb_new_subset_length_caplen(chunk_tvb, payload_offset, MIN(chunk_length - header_length, tvb_captured_length_remaining(chunk_tvb, payload_offset)), MIN(chunk_length - header_length, tvb_reported_length_remaining(chunk_tvb, payload_offset))); @@ -3557,7 +3557,7 @@ dissect_init_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo /* handle variable parameters */ chunk_length -= INIT_CHUNK_FIXED_PARAMTERS_LENGTH; - parameters_tvb = tvb_new_subset(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET, + parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET, MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET)), MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET))); dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, TRUE); @@ -3591,7 +3591,7 @@ dissect_init_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *p } /* handle variable paramters */ chunk_length -= INIT_CHUNK_FIXED_PARAMTERS_LENGTH; - parameters_tvb = tvb_new_subset(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET, + parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET, MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET)), MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET))); dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, TRUE); @@ -3924,7 +3924,7 @@ dissect_heartbeat_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info * if (chunk_tree) { proto_item_append_text(chunk_item, " (Information: %u byte%s)", chunk_length - CHUNK_HEADER_LENGTH, plurality(chunk_length - CHUNK_HEADER_LENGTH, "", "s")); - parameter_tvb = tvb_new_subset(chunk_tvb, HEARTBEAT_CHUNK_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(chunk_tvb, HEARTBEAT_CHUNK_INFO_OFFSET, MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, HEARTBEAT_CHUNK_INFO_OFFSET)), MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, HEARTBEAT_CHUNK_INFO_OFFSET))); /* FIXME: Parameters or parameter? */ @@ -3941,7 +3941,7 @@ dissect_heartbeat_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_in if (chunk_tree) { proto_item_append_text(chunk_item, " (Information: %u byte%s)", chunk_length - CHUNK_HEADER_LENGTH, plurality(chunk_length - CHUNK_HEADER_LENGTH, "", "s")); - parameter_tvb = tvb_new_subset(chunk_tvb, HEARTBEAT_ACK_CHUNK_INFO_OFFSET, + parameter_tvb = tvb_new_subset_length_caplen(chunk_tvb, HEARTBEAT_ACK_CHUNK_INFO_OFFSET, MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, HEARTBEAT_ACK_CHUNK_INFO_OFFSET)), MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, HEARTBEAT_ACK_CHUNK_INFO_OFFSET))); /* FIXME: Parameters or parameter? */ @@ -3964,7 +3964,7 @@ dissect_abort_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinf if (chunk_tree) { flags_tree = proto_item_add_subtree(flags_item, ett_sctp_abort_chunk_flags); proto_tree_add_item(flags_tree, hf_abort_chunk_t_bit, chunk_tvb, CHUNK_FLAGS_OFFSET, CHUNK_FLAGS_LENGTH, ENC_BIG_ENDIAN); - causes_tvb = tvb_new_subset(chunk_tvb, CHUNK_VALUE_OFFSET, + causes_tvb = tvb_new_subset_length_caplen(chunk_tvb, CHUNK_VALUE_OFFSET, MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, CHUNK_VALUE_OFFSET)), MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, CHUNK_VALUE_OFFSET))); dissect_error_causes(causes_tvb, pinfo, chunk_tree); @@ -3996,7 +3996,7 @@ dissect_error_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinf tvbuff_t *causes_tvb; if (chunk_tree) { - causes_tvb = tvb_new_subset(chunk_tvb, ERROR_CAUSE_IND_CAUSES_OFFSET, + causes_tvb = tvb_new_subset_length_caplen(chunk_tvb, ERROR_CAUSE_IND_CAUSES_OFFSET, MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, ERROR_CAUSE_IND_CAUSES_OFFSET)), MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, ERROR_CAUSE_IND_CAUSES_OFFSET))); dissect_error_causes(causes_tvb, pinfo, chunk_tree); @@ -4155,7 +4155,7 @@ dissect_re_config_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info * { tvbuff_t *parameters_tvb; - parameters_tvb = tvb_new_subset(chunk_tvb, RE_CONFIG_PARAMETERS_OFFSET, + parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, RE_CONFIG_PARAMETERS_OFFSET, MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, RE_CONFIG_PARAMETERS_OFFSET)), MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, RE_CONFIG_PARAMETERS_OFFSET))); dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, FALSE); @@ -4198,7 +4198,7 @@ dissect_asconf_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pin proto_tree_add_item(chunk_tree, hf_asconf_seq_nr, chunk_tvb, SEQUENCE_NUMBER_OFFSET, SCTP_SEQUENCE_NUMBER_LENGTH, ENC_BIG_ENDIAN); } chunk_length -= CHUNK_HEADER_LENGTH + SCTP_SEQUENCE_NUMBER_LENGTH; - parameters_tvb = tvb_new_subset(chunk_tvb, ASCONF_CHUNK_PARAMETERS_OFFSET, + parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, ASCONF_CHUNK_PARAMETERS_OFFSET, MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, ASCONF_CHUNK_PARAMETERS_OFFSET)), MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, ASCONF_CHUNK_PARAMETERS_OFFSET))); dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, FALSE); @@ -4221,7 +4221,7 @@ dissect_asconf_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info proto_tree_add_item(chunk_tree, hf_asconf_ack_seq_nr, chunk_tvb, SEQUENCE_NUMBER_OFFSET, SCTP_SEQUENCE_NUMBER_LENGTH, ENC_BIG_ENDIAN); } chunk_length -= CHUNK_HEADER_LENGTH + SCTP_SEQUENCE_NUMBER_LENGTH; - parameters_tvb = tvb_new_subset(chunk_tvb, ASCONF_ACK_CHUNK_PARAMETERS_OFFSET, + parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, ASCONF_ACK_CHUNK_PARAMETERS_OFFSET, MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, ASCONF_ACK_CHUNK_PARAMETERS_OFFSET)), MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, ASCONF_ACK_CHUNK_PARAMETERS_OFFSET))); dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, FALSE); @@ -4276,7 +4276,7 @@ dissect_pktdrop_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pi return; } chunk_length -= PKTDROP_CHUNK_HEADER_LENGTH; - data_field_tvb = tvb_new_subset(chunk_tvb, PKTDROP_CHUNK_DATA_FIELD_OFFSET, + data_field_tvb = tvb_new_subset_length_caplen(chunk_tvb, PKTDROP_CHUNK_DATA_FIELD_OFFSET, MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, PKTDROP_CHUNK_DATA_FIELD_OFFSET)), MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, PKTDROP_CHUNK_DATA_FIELD_OFFSET))); @@ -4530,7 +4530,7 @@ dissect_sctp_chunks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_i total_length = MIN(total_length, remaining_length); /* create a tvb for the chunk including the padding bytes */ - chunk_tvb = tvb_new_subset(tvb, offset, MIN(total_length, tvb_captured_length_remaining(tvb, offset)), total_length); + chunk_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(total_length, tvb_captured_length_remaining(tvb, offset)), total_length); /* save it in the sctp_info structure */ if (!encapsulated) { diff --git a/epan/dissectors/packet-selfm.c b/epan/dissectors/packet-selfm.c index 70dea920cc..03f98785d3 100644 --- a/epan/dissectors/packet-selfm.c +++ b/epan/dissectors/packet-selfm.c @@ -1699,7 +1699,7 @@ dissect_fastmsg_readresp_frame(tvbuff_t *tvb, proto_tree *fastmsg_tree, packet_i offset += 6; /* Setup a new tvb representing just the data payload of this particular message */ - data_tvb = tvb_new_subset( tvb, offset, (tvb_reported_length_remaining(tvb, offset)-2), (tvb_reported_length_remaining(tvb, offset)-2)); + data_tvb = tvb_new_subset_length_caplen( tvb, offset, (tvb_reported_length_remaining(tvb, offset)-2), (tvb_reported_length_remaining(tvb, offset)-2)); save_fragmented = pinfo->fragmented; diff --git a/epan/dissectors/packet-sflow.c b/epan/dissectors/packet-sflow.c index 19633ab941..8285f99e6d 100644 --- a/epan/dissectors/packet-sflow.c +++ b/epan/dissectors/packet-sflow.c @@ -673,7 +673,7 @@ dissect_sflow_245_sampled_header(tvbuff_t *tvb, packet_info *pinfo, /* hand the header off to the appropriate dissector. It's probably * a short frame, so ignore any exceptions. */ - next_tvb = tvb_new_subset(tvb, offset, header_length, frame_length); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, header_length, frame_length); /* save some state */ save_writable = col_get_writable(pinfo->cinfo, -1); diff --git a/epan/dissectors/packet-simple.c b/epan/dissectors/packet-simple.c index 39d7771e98..962f10f4fe 100644 --- a/epan/dissectors/packet-simple.c +++ b/epan/dissectors/packet-simple.c @@ -300,7 +300,7 @@ static void dissect_simple_link16(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t case SIMPLE_LINK16_FIXED_FORMAT: memset(&state, 0, sizeof(state)); for (i = 0; i < word_count; i += 5) { - newtvb = tvb_new_subset(tvb, offset, 10, -1); + newtvb = tvb_new_subset_length_caplen(tvb, offset, 10, -1); add_new_data_source(pinfo, newtvb, "Link 16 Word"); call_dissector_with_data(link16_handle, newtvb, pinfo, tree, &state); offset += 10; diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index b4f08afe52..73fd297c8b 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -1714,7 +1714,7 @@ display_sip_uri (tvbuff_t *tvb, proto_tree *sip_element_tree, packet_info *pinfo /* If we have a SIP diagnostics sub dissector call it */ if (sip_uri_userinfo_handle) { - next_tvb = tvb_new_subset(tvb, uri_offsets->uri_user_start, uri_offsets->uri_user_end - uri_offsets->uri_user_start + 1, + next_tvb = tvb_new_subset_length_caplen(tvb, uri_offsets->uri_user_start, uri_offsets->uri_user_end - uri_offsets->uri_user_start + 1, uri_offsets->uri_user_end - uri_offsets->uri_user_start + 1); call_dissector(sip_uri_userinfo_handle, next_tvb, pinfo, uri_item_tree); } @@ -2594,7 +2594,7 @@ static void dissect_sip_via_header(tvbuff_t *tvb, proto_tree *tree, gint start_o if (sip_via_branch_handle && g_ascii_strcasecmp (param_name, "branch") == 0) { tvbuff_t *next_tvb; - next_tvb = tvb_new_subset(tvb, parameter_name_end + 1, current_offset - parameter_name_end - 1, current_offset - parameter_name_end - 1); + next_tvb = tvb_new_subset_length_caplen(tvb, parameter_name_end + 1, current_offset - parameter_name_end - 1, current_offset - parameter_name_end - 1); call_dissector (sip_via_branch_handle, next_tvb, pinfo, tree); } @@ -4273,7 +4273,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info message_body_tree = proto_item_add_subtree(ti_a, ett_sip_message_body); } } else { - next_tvb = tvb_new_subset(tvb, offset, datalen, reported_datalen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, datalen, reported_datalen); if(sip_tree) { ti_a = proto_tree_add_item(sip_tree, hf_sip_msg_body, next_tvb, 0, -1, ENC_NA); @@ -4281,7 +4281,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info } } }else{ - next_tvb = tvb_new_subset(tvb, offset, datalen, reported_datalen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, datalen, reported_datalen); if(sip_tree) { ti_a = proto_tree_add_item(sip_tree, hf_sip_msg_body, next_tvb, 0, -1, ENC_NA); diff --git a/epan/dissectors/packet-skinny.c b/epan/dissectors/packet-skinny.c index 6334b13267..345363ec94 100644 --- a/epan/dissectors/packet-skinny.c +++ b/epan/dissectors/packet-skinny.c @@ -2243,7 +2243,7 @@ dissect_skinny_xml(ptvcursor_t *cursor, int hfindex, packet_info *pinfo, guint32 item = proto_tree_add_item(tree, hf_skinny_xmlData, tvb, offset, length, ENC_ASCII|ENC_NA); subtree = proto_item_add_subtree(item, 0); - next_tvb = tvb_new_subset(tvb, offset, length, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, -1); if (xml_handle != NULL) { call_dissector(xml_handle, next_tvb, pinfo, subtree); } diff --git a/epan/dissectors/packet-skinny.c.in b/epan/dissectors/packet-skinny.c.in index c0779d8638..162f2f0c6e 100644 --- a/epan/dissectors/packet-skinny.c.in +++ b/epan/dissectors/packet-skinny.c.in @@ -217,7 +217,7 @@ dissect_skinny_xml(ptvcursor_t *cursor, int hfindex, packet_info *pinfo, guint32 item = proto_tree_add_item(tree, hf_skinny_xmlData, tvb, offset, length, ENC_ASCII|ENC_NA); subtree = proto_item_add_subtree(item, 0); - next_tvb = tvb_new_subset(tvb, offset, length, -1); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, -1); if (xml_handle != NULL) { call_dissector(xml_handle, next_tvb, pinfo, subtree); } diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 182e8ac506..d6e9dd55d6 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -3016,7 +3016,7 @@ dissect_negprot_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in * we'll throw the right exception if * it's too short. */ - gssapi_tvb = tvb_new_subset( + gssapi_tvb = tvb_new_subset_length_caplen( tvb, offset, sbloblen, bc); call_dissector( @@ -4661,7 +4661,7 @@ dissect_file_data_dcerpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bc = datalen; } tvblen = tvb_reported_length_remaining(tvb, offset); - dcerpc_tvb = tvb_new_subset(tvb, offset, tvblen, bc); + dcerpc_tvb = tvb_new_subset_length_caplen(tvb, offset, tvblen, bc); dissect_pipe_dcerpc(dcerpc_tvb, pinfo, top_tree, tree, fid, data); if (bc > tvblen) offset += tvblen; @@ -7456,7 +7456,7 @@ dissect_session_setup_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree * data available from the blob, so that we'll * throw the right exception if it's too short. */ - blob_tvb = tvb_new_subset(tvb, offset, sbloblen_short, + blob_tvb = tvb_new_subset_length_caplen(tvb, offset, sbloblen_short, sbloblen); if (si && si->ct && si->ct->raw_ntlmssp && @@ -8798,7 +8798,7 @@ dissect_nt_trans_data_request(tvbuff_t *tvb, packet_info *pinfo, int offset, pro break; case NT_TRANS_IOCTL: /* ioctl data */ - ioctl_tvb = tvb_new_subset(tvb, offset, MIN((int)bc, tvb_reported_length_remaining(tvb, offset)), bc); + ioctl_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN((int)bc, tvb_reported_length_remaining(tvb, offset)), bc); if (nti) { dissect_smb2_ioctl_data(ioctl_tvb, pinfo, tree, top_tree_global, nti->ioctl_function, TRUE, NULL); } @@ -9395,7 +9395,7 @@ dissect_nt_trans_data_response(tvbuff_t *tvb, packet_info *pinfo, break; case NT_TRANS_IOCTL: /* ioctl data */ - ioctl_tvb = tvb_new_subset(tvb, offset, MIN((int)len, tvb_reported_length_remaining(tvb, offset)), len); + ioctl_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN((int)len, tvb_reported_length_remaining(tvb, offset)), len); dissect_smb2_ioctl_data(ioctl_tvb, pinfo, tree, top_tree_global, nti->ioctl_function, FALSE, NULL); offset += len; @@ -14142,7 +14142,7 @@ dissect_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (pc > 0) { if (pc>tvb_reported_length_remaining(tvb, po)) { - p_tvb = tvb_new_subset(tvb, po, tvb_reported_length_remaining(tvb, po), pc); + p_tvb = tvb_new_subset_length_caplen(tvb, po, tvb_reported_length_remaining(tvb, po), pc); } else { p_tvb = tvb_new_subset_length(tvb, po, pc); } @@ -14151,7 +14151,7 @@ dissect_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } if (dc > 0) { if (dc>tvb_reported_length_remaining(tvb, od)) { - d_tvb = tvb_new_subset(tvb, od, tvb_reported_length_remaining(tvb, od), dc); + d_tvb = tvb_new_subset_length_caplen(tvb, od, tvb_reported_length_remaining(tvb, od), dc); } else { d_tvb = tvb_new_subset_length(tvb, od, dc); } @@ -14160,7 +14160,7 @@ dissect_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } if (sl) { if (sl>tvb_reported_length_remaining(tvb, so)) { - s_tvb = tvb_new_subset(tvb, so, tvb_reported_length_remaining(tvb, so), sl); + s_tvb = tvb_new_subset_length_caplen(tvb, so, tvb_reported_length_remaining(tvb, so), sl); } else { s_tvb = tvb_new_subset_length(tvb, so, sl); } @@ -16646,7 +16646,7 @@ dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree /* if there were any setup bytes, put them in a tvb for later */ if (sc) { if ((2*sc) > tvb_reported_length_remaining(tvb, offset)) { - s_tvb = tvb_new_subset(tvb, offset, tvb_reported_length_remaining(tvb, offset), 2*sc); + s_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), 2*sc); } else { s_tvb = tvb_new_subset_length(tvb, offset, 2*sc); } @@ -16718,12 +16718,12 @@ dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree min = MIN(pc, tvb_reported_length_remaining(tvb, po)); reported_min = MIN(pc, tvb_reported_length_remaining(tvb, po)); if (min && reported_min) { - p_tvb = tvb_new_subset(tvb, po, min, reported_min); + p_tvb = tvb_new_subset_length_caplen(tvb, po, min, reported_min); } min = MIN(dc, tvb_reported_length_remaining(tvb, od)); reported_min = MIN(dc, tvb_reported_length_remaining(tvb, od)); if (min && reported_min) { - d_tvb = tvb_new_subset(tvb, od, min, reported_min); + d_tvb = tvb_new_subset_length_caplen(tvb, od, min, reported_min); } /* * A tvbuff containing the parameters diff --git a/epan/dissectors/packet-smb2.c b/epan/dissectors/packet-smb2.c index 267887857c..dc76c1c0ef 100644 --- a/epan/dissectors/packet-smb2.c +++ b/epan/dissectors/packet-smb2.c @@ -1344,7 +1344,7 @@ dissect_smb2_olb_buffer(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *t return; } - sub_tvb = tvb_new_subset(tvb, off, MIN((int)len, tvb_captured_length_remaining(tvb, off)), len); + sub_tvb = tvb_new_subset_length_caplen(tvb, off, MIN((int)len, tvb_captured_length_remaining(tvb, off)), len); dissector(sub_tvb, pinfo, sub_tree, si); } @@ -4891,7 +4891,7 @@ dissect_file_data_smb2_pipe(tvbuff_t *raw_tvb, packet_info *pinfo, proto_tree *t remaining = tvb_captured_length_remaining(raw_tvb, offset); - tvb = tvb_new_subset(raw_tvb, offset, + tvb = tvb_new_subset_length_caplen(raw_tvb, offset, MIN((int)datalen, remaining), datalen); diff --git a/epan/dissectors/packet-smpp.c b/epan/dissectors/packet-smpp.c index 45b33f1574..48b1ba8517 100644 --- a/epan/dissectors/packet-smpp.c +++ b/epan/dissectors/packet-smpp.c @@ -1961,7 +1961,7 @@ submit_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, /* Set SMPP source and destination address */ set_address(&(pinfo->src), AT_STRINGZ, 1+(int)strlen(src_str), src_str); set_address(&(pinfo->dst), AT_STRINGZ, 1+(int)strlen(dst_str), dst_str); - tvb_msg = tvb_new_subset (tvb, offset, + tvb_msg = tvb_new_subset_length_caplen (tvb, offset, MIN(length, tvb_reported_length(tvb) - offset), length); call_dissector (gsm_sms_handle, tvb_msg, pinfo, top_tree); /* Restore original addresses */ @@ -2391,7 +2391,7 @@ dissect_smpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) return offset; if (pdu_real_len > pdu_len) pdu_real_len = pdu_len; - pdu_tvb = tvb_new_subset(tvb, offset, pdu_real_len, pdu_len); + pdu_tvb = tvb_new_subset_length_caplen(tvb, offset, pdu_real_len, pdu_len); dissect_smpp_pdu(pdu_tvb, pinfo, tree, data); offset += pdu_len; first = FALSE; @@ -2493,11 +2493,11 @@ dissect_smpp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data * Reported length: command_length */ if (tvb_captured_length_remaining(tvb, offset - 16 + command_length) > 0) { - pdu_tvb = tvb_new_subset(tvb, offset - 16, + pdu_tvb = tvb_new_subset_length_caplen(tvb, offset - 16, command_length, /* Physical length */ command_length); /* Length reported by the protocol */ } else { - pdu_tvb = tvb_new_subset(tvb, offset - 16, + pdu_tvb = tvb_new_subset_length_caplen(tvb, offset - 16, tvb_captured_length_remaining(tvb, offset - 16),/* Physical length */ command_length); /* Length reported by the protocol */ } @@ -2549,7 +2549,7 @@ dissect_smpp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data */ if (command_length <= tvb_reported_length(pdu_tvb)) { - tvbuff_t *tmp_tvb = tvb_new_subset(pdu_tvb, 16, + tvbuff_t *tmp_tvb = tvb_new_subset_length_caplen(pdu_tvb, 16, -1, command_length - 16); if (command_id & 0x80000000) { diff --git a/epan/dissectors/packet-sna.c b/epan/dissectors/packet-sna.c index cfd27fd762..b4851916b1 100644 --- a/epan/dissectors/packet-sna.c +++ b/epan/dissectors/packet-sna.c @@ -1164,35 +1164,35 @@ dissect_optional(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } switch(type) { case 0x0d: - dissect_optional_0d(tvb_new_subset(tvb, offset, + dissect_optional_0d(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), sub_tree); break; case 0x0e: - dissect_optional_0e(tvb_new_subset(tvb, offset, + dissect_optional_0e(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), pinfo, sub_tree); break; case 0x0f: - dissect_optional_0f(tvb_new_subset(tvb, offset, + dissect_optional_0f(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), pinfo, sub_tree); break; case 0x10: - dissect_optional_10(tvb_new_subset(tvb, offset, + dissect_optional_10(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), pinfo, sub_tree); break; case 0x12: - dissect_optional_12(tvb_new_subset(tvb, offset, + dissect_optional_12(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), sub_tree); break; case 0x14: - dissect_optional_14(tvb_new_subset(tvb, offset, + dissect_optional_14(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), pinfo, sub_tree); break; case 0x22: - dissect_optional_22(tvb_new_subset(tvb, offset, + dissect_optional_22(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), pinfo, sub_tree); break; default: - call_data_dissector(tvb_new_subset(tvb, offset, + call_data_dissector(tvb_new_subset_length_caplen(tvb, offset, len << 2, -1), pinfo, sub_tree); } offset += (len << 2); @@ -1338,14 +1338,14 @@ dissect_nlp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (tvb_get_guint8(tvb, indx+subindx+1) == 5) dissect_control(tvb, indx + subindx, counter+2, nlp_tree, 1, LT); else - call_data_dissector(tvb_new_subset(tvb, indx + subindx, counter+2, + call_data_dissector(tvb_new_subset_length_caplen(tvb, indx + subindx, counter+2, -1), pinfo, nlp_tree); subindx += (counter+2); } if ((thdr_9 & 0x04) && ((thdr_len << 2) > subindx)) dissect_optional( - tvb_new_subset(tvb, indx + subindx, + tvb_new_subset_length_caplen(tvb, indx + subindx, (thdr_len << 2) - subindx, -1), pinfo, nlp_tree); @@ -1541,20 +1541,20 @@ dissect_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, case 0: break; case 1: - dissect_xid1(tvb_new_subset(tvb, 6, len-6, -1), + dissect_xid1(tvb_new_subset_length_caplen(tvb, 6, len-6, -1), tree); break; case 2: - dissect_xid2(tvb_new_subset(tvb, 6, len-6, -1), + dissect_xid2(tvb_new_subset_length_caplen(tvb, 6, len-6, -1), tree); break; case 3: - dissect_xid3(tvb_new_subset(tvb, 6, len-6, -1), + dissect_xid3(tvb_new_subset_length_caplen(tvb, 6, len-6, -1), tree); break; default: /* external standards organizations */ - call_data_dissector(tvb_new_subset(tvb, 6, len-6, -1), + call_data_dissector(tvb_new_subset_length_caplen(tvb, 6, len-6, -1), pinfo, tree); } } @@ -2316,7 +2316,7 @@ dissect_control(tvbuff_t *parent_tvb, int offset, int control_len, length = control_len; if (control_len < reported_length) reported_length = control_len; - tvb = tvb_new_subset(parent_tvb, offset, length, reported_length); + tvb = tvb_new_subset_length_caplen(parent_tvb, offset, length, reported_length); sub_tree = NULL; diff --git a/epan/dissectors/packet-spnego.c b/epan/dissectors/packet-spnego.c index 306a6ad315..9c96f23fd4 100644 --- a/epan/dissectors/packet-spnego.c +++ b/epan/dissectors/packet-spnego.c @@ -1493,7 +1493,7 @@ dissect_spnego_krb5_cfx_wrap_base(tvbuff_t *tvb, int offset, packet_info *pinfo */ return offset; } - gssapi_encrypt->gssapi_encrypted_tvb = tvb_new_subset( + gssapi_encrypt->gssapi_encrypted_tvb = tvb_new_subset_length_caplen( tvb, offset, len, len); } diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c index 4c37e281cb..fd43a98a2c 100644 --- a/epan/dissectors/packet-synphasor.c +++ b/epan/dissectors/packet-synphasor.c @@ -555,7 +555,7 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v else { /* create a new tvb to pass to the subdissector '-16': length of header + 2 CRC bytes */ - sub_tvb = tvb_new_subset(tvb, offset, tvbsize - 16, framesize - 16); + sub_tvb = tvb_new_subset_length_caplen(tvb, offset, tvbsize - 16, framesize - 16); /* call subdissector */ switch (frame_type) { diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 6fd413352c..e6c5aa5209 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -3475,7 +3475,7 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, length = captured_length_remaining; if (length > plen) length = plen; - next_tvb = tvb_new_subset(tvb, offset, length, plen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, plen); /* * Dissect the PDU. diff --git a/epan/dissectors/packet-tds.c b/epan/dissectors/packet-tds.c index fee8a0b07b..7e92309b77 100644 --- a/epan/dissectors/packet-tds.c +++ b/epan/dissectors/packet-tds.c @@ -1193,7 +1193,7 @@ dissect_tds_nt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, { tvbuff_t *nt_tvb; - nt_tvb = tvb_new_subset(tvb, offset, -1, length); + nt_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, length); if(tvb_strneql(tvb, offset, "NTLMSSP", 7) == 0) call_dissector(ntlmssp_handle, nt_tvb, pinfo, tree); else @@ -4074,7 +4074,7 @@ dissect_tds_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * length = length_remaining; if (length > plen) length = plen; - next_tvb = tvb_new_subset(tvb, offset, length, plen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, plen); /* * Dissect the Netlib buffer. diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c index a8d9022e59..9eae0df181 100644 --- a/epan/dissectors/packet-tftp.c +++ b/epan/dissectors/packet-tftp.c @@ -424,7 +424,7 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info, /* Show data in tree */ if (bytes > 0) { - data_tvb = tvb_new_subset(tvb, offset, -1, bytes); + data_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, bytes); call_data_dissector(data_tvb, pinfo, tree); } diff --git a/epan/dissectors/packet-tipc.c b/epan/dissectors/packet-tipc.c index e15f7d4fd9..b77a0792e3 100644 --- a/epan/dissectors/packet-tipc.c +++ b/epan/dissectors/packet-tipc.c @@ -1474,14 +1474,14 @@ dissect_tipc_v2_internal_msg(tvbuff_t *tipc_tvb, proto_tree *tipc_tree, packet_i col_set_fence(pinfo->cinfo, COL_INFO); dissect_tipc(new_tvb, pinfo, top_tree, NULL); } else { /* make a new subset */ - data_tvb = tvb_new_subset(tipc_tvb, offset, len, reported_len); + data_tvb = tvb_new_subset_length_caplen(tipc_tvb, offset, len, reported_len); call_data_dissector(data_tvb, pinfo, top_tree); } pinfo->fragmented = save_fragmented; } else { /* don't reassemble is set in the "preferences" */ - data_tvb = tvb_new_subset(tipc_tvb, offset, len, reported_len); + data_tvb = tvb_new_subset_length_caplen(tipc_tvb, offset, len, reported_len); call_data_dissector(data_tvb, pinfo, top_tree); } @@ -1809,7 +1809,7 @@ dissect_tipc_v2(tvbuff_t *tipc_tvb, proto_tree *tipc_tree, packet_info *pinfo, i /* TIPCv2 data */ len = (msg_size - (orig_hdr_size<<2)); reported_len = tvb_reported_length_remaining(tipc_tvb, offset); - data_tvb = tvb_new_subset(tipc_tvb, offset, len, reported_len); + data_tvb = tvb_new_subset_length_caplen(tipc_tvb, offset, len, reported_len); call_tipc_v2_data_subdissectors(data_tvb, pinfo, name_type_p, user); } diff --git a/epan/dissectors/packet-tpkt.c b/epan/dissectors/packet-tpkt.c index 937769c175..edc1952c86 100644 --- a/epan/dissectors/packet-tpkt.c +++ b/epan/dissectors/packet-tpkt.c @@ -327,7 +327,7 @@ dissect_asciitpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (length > data_len) length = data_len; - next_tvb = tvb_new_subset(tvb, offset,length, data_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset,length, data_len); /* * Call the subdissector. @@ -531,7 +531,7 @@ dissect_tpkt_encap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, length = length_remaining - 4; if (length > data_len) length = data_len; - next_tvb = tvb_new_subset(tvb, offset, length, data_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, data_len); /* * Call the subdissector. diff --git a/epan/dissectors/packet-turbocell.c b/epan/dissectors/packet-turbocell.c index ad81e939ef..b6dccf850c 100644 --- a/epan/dissectors/packet-turbocell.c +++ b/epan/dissectors/packet-turbocell.c @@ -189,7 +189,7 @@ dissect_turbocell(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat proto_tree *mpdu_tree; proto_tree *subframe_tree; - next_tvb = tvb_new_subset(tvb, 0x14, -1, tvb_get_ntohs(tvb, 0x14)); + next_tvb = tvb_new_subset_length_caplen(tvb, 0x14, -1, tvb_get_ntohs(tvb, 0x14)); parent_item = proto_tree_add_protocol_format(tree, proto_aggregate, next_tvb, 0, tvb_reported_length_remaining(next_tvb, 0), "Turbocell Aggregate Frames"); mpdu_tree = proto_item_add_subtree(parent_item, ett_msdu_aggregation_parent_tree); @@ -212,7 +212,7 @@ dissect_turbocell(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat msdu_offset += 0x02; remaining_length -= 0x02; - msdu_tvb = tvb_new_subset(next_tvb, msdu_offset, (msdu_length>remaining_length)?remaining_length:msdu_length, msdu_length); + msdu_tvb = tvb_new_subset_length_caplen(next_tvb, msdu_offset, (msdu_length>remaining_length)?remaining_length:msdu_length, msdu_length); call_dissector(eth_handle, msdu_tvb, pinfo, subframe_tree); msdu_offset += msdu_length; remaining_length -= msdu_length; diff --git a/epan/dissectors/packet-turnchannel.c b/epan/dissectors/packet-turnchannel.c index d1b4f2f2a8..616cca3fd2 100644 --- a/epan/dissectors/packet-turnchannel.c +++ b/epan/dissectors/packet-turnchannel.c @@ -105,7 +105,7 @@ dissect_turnchannel_message(tvbuff_t *tvb, packet_info *pinfo, if (data_len < reported_len) { reported_len = data_len; } - next_tvb = tvb_new_subset(tvb, TURNCHANNEL_HDR_LEN, new_len, + next_tvb = tvb_new_subset_length_caplen(tvb, TURNCHANNEL_HDR_LEN, new_len, reported_len); diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 5a36f1b22f..12fbf1768f 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -593,7 +593,7 @@ decode_udp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo, len = reported_len; } - next_tvb = tvb_new_subset(tvb, offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, len, reported_len); /* If the user has a "Follow UDP Stream" window loading, pass a pointer * to the payload tvb through the tap system. */ @@ -784,7 +784,7 @@ udp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, length = captured_length_remaining; if (length > plen) length = plen; - next_tvb = tvb_new_subset(tvb, offset, length, plen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, plen); /* * Dissect the PDU. diff --git a/epan/dissectors/packet-uftp.c b/epan/dissectors/packet-uftp.c index 91b629f70c..b20bd93846 100644 --- a/epan/dissectors/packet-uftp.c +++ b/epan/dissectors/packet-uftp.c @@ -1438,7 +1438,7 @@ static int dissect_uftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi proto_tree_add_item(uftp_tree, hf_uftp_destaddr, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - next_tvb = tvb_new_subset(tvb, offset, -1, blsize); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, blsize); switch (mes_type) { case ANNOUNCE: diff --git a/epan/dissectors/packet-uftp4.c b/epan/dissectors/packet-uftp4.c index bf77b664ba..3d58e3ae77 100644 --- a/epan/dissectors/packet-uftp4.c +++ b/epan/dissectors/packet-uftp4.c @@ -898,7 +898,7 @@ static gint dissect_uftp_encinfo(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr if (keylen > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, keylen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, keylen); blobtype = tvb_get_guint8(tvb, offset); switch (blobtype) { case KEYBLOB_RSA: @@ -913,7 +913,7 @@ static gint dissect_uftp_encinfo(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr if (dhlen > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, dhlen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, dhlen); blobtype = tvb_get_guint8(tvb, offset); switch (blobtype) { case KEYBLOB_RSA: @@ -995,7 +995,7 @@ static void dissect_uftp_announce(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t while (extlen_total > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, extlen_total); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, extlen_total); ext_type = tvb_get_guint8(tvb, offset); switch (ext_type) { case EXT_ENC_INFO: @@ -1111,7 +1111,7 @@ static void dissect_uftp_clientkey(tvbuff_t *tvb, packet_info *pinfo _U_, proto_ if (keylen > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, keylen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, keylen); blobtype = tvb_get_guint8(tvb, offset); switch (blobtype) { case KEYBLOB_RSA: @@ -1460,7 +1460,7 @@ static void dissect_uftp_fileseg(tvbuff_t *tvb, packet_info *pinfo, proto_tree * while (extlen_total > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, extlen_total); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, extlen_total); ext_type = tvb_get_guint8(tvb, offset); switch (ext_type) { case EXT_TFMCC_DATA_INFO: @@ -1619,7 +1619,7 @@ static void dissect_uftp_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t while (extlen_total > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, extlen_total); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, extlen_total); ext_type = tvb_get_guint8(tvb, offset); switch (ext_type) { case EXT_TFMCC_ACK_INFO: @@ -1715,7 +1715,7 @@ static void dissect_uftp_complete(tvbuff_t *tvb, packet_info *pinfo, proto_tree while (extlen_total > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, extlen_total); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, extlen_total); ext_type = tvb_get_guint8(tvb, offset); switch (ext_type) { case EXT_FREESPACE_INFO: @@ -1824,7 +1824,7 @@ static void dissect_uftp_hbreq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree if (keylen > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, keylen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, keylen); blobtype = tvb_get_guint8(tvb, offset); switch (blobtype) { case KEYBLOB_RSA: @@ -1947,7 +1947,7 @@ static void dissect_uftp_proxykey(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t if (keylen > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, keylen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, keylen); blobtype = tvb_get_guint8(tvb, offset); switch (blobtype) { case KEYBLOB_RSA: @@ -1962,7 +1962,7 @@ static void dissect_uftp_proxykey(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t if (dhlen > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, dhlen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, dhlen); blobtype = tvb_get_guint8(tvb, offset); switch (blobtype) { case KEYBLOB_RSA: @@ -2081,7 +2081,7 @@ static void dissect_uftp_ccack(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree while (extlen_total > 0) { gint parsed = 0; - next_tvb = tvb_new_subset(tvb, offset, -1, extlen_total); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, extlen_total); ext_type = tvb_get_guint8(tvb, offset); switch (ext_type) { case EXT_TFMCC_ACK_INFO: @@ -2221,7 +2221,7 @@ static int dissect_uftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi proto_tree_add_item(uftp_tree, hf_uftp_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - next_tvb = tvb_new_subset(tvb, offset, -1, tvb_reported_length(tvb) - UFTP_LEN); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, tvb_reported_length(tvb) - UFTP_LEN); switch (mes_type) { case ANNOUNCE: diff --git a/epan/dissectors/packet-umts_fp.c b/epan/dissectors/packet-umts_fp.c index 893c17201a..1044d8eed4 100644 --- a/epan/dissectors/packet-umts_fp.c +++ b/epan/dissectors/packet-umts_fp.c @@ -806,7 +806,7 @@ dissect_tb_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } if (crci_bit == 0 || !p_fp_info->is_uplink) { - next_tvb = tvb_new_subset(tvb, offset + bit_offset/8, + next_tvb = tvb_new_subset_length_caplen(tvb, offset + bit_offset/8, ((bit_offset % 8) + p_fp_info->chan_tf_size[chan] + 7) / 8, -1); @@ -894,7 +894,7 @@ dissect_macd_pdu_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } if (preferences_call_mac_dissectors /*&& !rlc_is_ciphered(pinfo)*/) { tvbuff_t *next_tvb; - next_tvb = tvb_new_subset(tvb, offset + bit_offset/8, + next_tvb = tvb_new_subset_length_caplen(tvb, offset + bit_offset/8, ((bit_offset % 8) + length + 7)/8, -1); call_dissector_with_data(mac_fdd_hsdsch_handle, next_tvb, pinfo, top_level_tree, data); dissected = TRUE; @@ -959,7 +959,7 @@ dissect_macd_pdu_data_type_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree if (preferences_call_mac_dissectors /*&& !rlc_is_ciphered(pinfo)*/) { - tvbuff_t *next_tvb = tvb_new_subset(tvb, offset, length, -1); + tvbuff_t *next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, -1); fpi->cur_tb = pdu; /*Set proper pdu index for MAC and higher layers*/ @@ -2845,7 +2845,7 @@ dissect_e_dch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tvbuff_t *next_tvb; pinfo->fd->subnum = macd_idx; /* set subframe number to current TB */ /* create new TVB and pass further on */ - next_tvb = tvb_new_subset(tvb, offset + bit_offset/8, + next_tvb = tvb_new_subset_length_caplen(tvb, offset + bit_offset/8, ((bit_offset % 8) + size + 7) / 8, -1); diff --git a/epan/dissectors/packet-umts_mac.c b/epan/dissectors/packet-umts_mac.c index ed4ea763f5..1c2e84e9e0 100644 --- a/epan/dissectors/packet-umts_mac.c +++ b/epan/dissectors/packet-umts_mac.c @@ -732,7 +732,7 @@ static tvbuff_t * add_to_tree(tvbuff_t * tvb, packet_info * pinfo, proto_tree * } return new_tvb; } else { - new_tvb = tvb_new_subset(tvb, offset, maclength, -1); + new_tvb = tvb_new_subset_length_caplen(tvb, offset, maclength, -1); switch (type) { case MAC_IS_HEAD: proto_tree_add_expert(tree, pinfo, &ei_mac_macis_sdu_first, new_tvb, 0, -1); @@ -845,7 +845,7 @@ static tvbuff_t * mac_is_add_fragment(tvbuff_t * tvb _U_, packet_info *pinfo, pr /* If our SDU is not fragmented. */ } else { DISSECTOR_ASSERT((sdu_no == 0) ? (ss&1) == 0 : ((sdu_no == no_sdus-1) ? (ss&2) == 0 : TRUE)); - return tvb_new_subset(tvb, offset, maclength, -1); + return tvb_new_subset_length_caplen(tvb, offset, maclength, -1); } /* If clicking on a packet. */ } else { @@ -871,7 +871,7 @@ static tvbuff_t * mac_is_add_fragment(tvbuff_t * tvb _U_, packet_info *pinfo, pr return add_to_tree(tvb, pinfo, tree, sdu, offset, maclength, MAC_IS_HEAD); } } else { - new_tvb = tvb_new_subset(tvb, offset, maclength, -1); + new_tvb = tvb_new_subset_length_caplen(tvb, offset, maclength, -1); proto_tree_add_expert(tree, pinfo, &ei_mac_macis_sdu_complete, new_tvb, 0, -1); proto_tree_add_item(tree, hf_mac_edch_type2_sdu_data, new_tvb, 0, -1, ENC_NA); return new_tvb; diff --git a/epan/dissectors/packet-usb-masstorage.c b/epan/dissectors/packet-usb-masstorage.c index bec12768af..9aa8118ac8 100644 --- a/epan/dissectors/packet-usb-masstorage.c +++ b/epan/dissectors/packet-usb-masstorage.c @@ -296,7 +296,7 @@ dissect_usb_ms_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, cdblen=tvb_captured_length_remaining(tvb, offset); } if(cdblen){ - cdb_tvb=tvb_new_subset(tvb, offset, cdblen, cdbrlen); + cdb_tvb=tvb_new_subset_length_caplen(tvb, offset, cdblen, cdbrlen); dissect_scsi_cdb(cdb_tvb, pinfo, parent_tree, SCSI_DEV_UNKNOWN, itlq, itl); } return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-usb-video.c b/epan/dissectors/packet-usb-video.c index 3bf08f6156..41dc5f4b32 100644 --- a/epan/dissectors/packet-usb-video.c +++ b/epan/dissectors/packet-usb-video.c @@ -1477,7 +1477,7 @@ dissect_usb_vid_descriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, descriptor_type = tvb_get_guint8(tvb, offset+1); bytes_available = tvb_captured_length_remaining(tvb, offset); - desc_tvb = tvb_new_subset(tvb, 0, bytes_available, descriptor_len); + desc_tvb = tvb_new_subset_length_caplen(tvb, 0, bytes_available, descriptor_len); if (descriptor_type == CS_ENDPOINT) { diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index 19bd76c243..c53716b444 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -3328,7 +3328,7 @@ dissect_usb_setup_request(packet_info *pinfo, proto_tree *tree, if (tvb_captured_length_remaining(tvb, offset) > 0) { next_tvb = tvb_new_composite(); - tvb_composite_append(next_tvb, tvb_new_subset(tvb, setup_offset, 7, 7)); + tvb_composite_append(next_tvb, tvb_new_subset_length_caplen(tvb, setup_offset, 7, 7)); data_tvb = tvb_new_subset_remaining(tvb, offset); tvb_composite_append(next_tvb, data_tvb); @@ -3340,7 +3340,7 @@ dissect_usb_setup_request(packet_info *pinfo, proto_tree *tree, tvb_captured_length(next_tvb)); add_new_data_source(pinfo, next_tvb, "USB Control"); } else { - next_tvb = tvb_new_subset(tvb, setup_offset, 7, 7); + next_tvb = tvb_new_subset_length_caplen(tvb, setup_offset, 7, 7); } /* at this point, offset contains the number of bytes that we diff --git a/epan/dissectors/packet-user_encap.c b/epan/dissectors/packet-user_encap.c index 7e2f2c01e3..2a0d778fa8 100644 --- a/epan/dissectors/packet-user_encap.c +++ b/epan/dissectors/packet-user_encap.c @@ -170,7 +170,7 @@ static int dissect_user(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, voi len = tvb_captured_length(tvb) - (encap->header_size + encap->trailer_size); reported_len = tvb_reported_length(tvb) - (encap->header_size + encap->trailer_size); - payload_tvb = tvb_new_subset(tvb, encap->header_size, len, reported_len); + payload_tvb = tvb_new_subset_length_caplen(tvb, encap->header_size, len, reported_len); export_pdu(payload_tvb, pinfo, encap->payload_proto_name); call_dissector(encap->payload_proto, payload_tvb, pinfo, tree); if (encap->payload_proto_name) { diff --git a/epan/dissectors/packet-v5dl.c b/epan/dissectors/packet-v5dl.c index 6dc1603142..28738a318e 100644 --- a/epan/dissectors/packet-v5dl.c +++ b/epan/dissectors/packet-v5dl.c @@ -251,7 +251,7 @@ dissect_v5dl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ /* * Remove the V5DL header *and* the checksum. */ - next_tvb = tvb_new_subset(tvb, v5dl_header_len, + next_tvb = tvb_new_subset_length_caplen(tvb, v5dl_header_len, tvb_captured_length_remaining(tvb, v5dl_header_len) - 2, tvb_reported_length_remaining(tvb, v5dl_header_len) - 2); } else { @@ -266,7 +266,7 @@ dissect_v5dl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ * Remove that byte from the captured length * and both bytes from the reported length. */ - next_tvb = tvb_new_subset(tvb, v5dl_header_len, + next_tvb = tvb_new_subset_length_caplen(tvb, v5dl_header_len, tvb_captured_length_remaining(tvb, v5dl_header_len) - 1, tvb_reported_length_remaining(tvb, v5dl_header_len) - 2); } else { @@ -276,7 +276,7 @@ dissect_v5dl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ * Just remove the checksum from the reported * length. */ - next_tvb = tvb_new_subset(tvb, v5dl_header_len, + next_tvb = tvb_new_subset_length_caplen(tvb, v5dl_header_len, tvb_captured_length_remaining(tvb, v5dl_header_len), tvb_reported_length_remaining(tvb, v5dl_header_len) - 2); } diff --git a/epan/dissectors/packet-websocket.c b/epan/dissectors/packet-websocket.c index 289775b952..9ba8bb595c 100644 --- a/epan/dissectors/packet-websocket.c +++ b/epan/dissectors/packet-websocket.c @@ -275,7 +275,7 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p return; } /* Right now this is exactly the same, this may change when exts. are added. - tvb_appdata = tvb_new_subset(tvb, offset, length, length); + tvb_appdata = tvb_new_subset_length_caplen(tvb, offset, length, length); */ tvb_appdata = tvb; @@ -362,7 +362,7 @@ dissect_websocket_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi tvb_set_child_real_data_tvbuff(tvb, tvb_payload); add_new_data_source(pinfo, tvb_payload, "Unmasked data"); } else { - tvb_payload = tvb_new_subset(tvb, payload_offset, payload_length, payload_length); + tvb_payload = tvb_new_subset_length_caplen(tvb, payload_offset, payload_length, payload_length); } dissect_websocket_payload(tvb_payload, pinfo, tree, ws_tree, opcode); } diff --git a/epan/dissectors/packet-wsmp.c b/epan/dissectors/packet-wsmp.c index 8a06357e7e..189d209819 100644 --- a/epan/dissectors/packet-wsmp.c +++ b/epan/dissectors/packet-wsmp.c @@ -185,7 +185,7 @@ dissect_wsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ wsmdata_tree = proto_tree_add_subtree(wsmp_tree, tvb, offset, wsmlength, ett_wsmdata, NULL, "Wave Short Message"); - wsmdata_tvb = tvb_new_subset(tvb, offset, -1, wsmlength); + wsmdata_tvb = tvb_new_subset_length_caplen(tvb, offset, -1, wsmlength); /* TODO: Branch on the application context and display accordingly * Default: call the data dissector diff --git a/epan/dissectors/packet-x11.c b/epan/dissectors/packet-x11.c index 95ce5fa728..82bd4dfc16 100644 --- a/epan/dissectors/packet-x11.c +++ b/epan/dissectors/packet-x11.c @@ -1159,7 +1159,7 @@ static const value_string zero_is_none_vals[] = { unsigned char eventcode; \ const char *sent; \ proto_tree *event_proto_tree; \ - next_tvb = tvb_new_subset(tvb, offset, next_offset - offset, \ + next_tvb = tvb_new_subset_length_caplen(tvb, offset, next_offset - offset, \ next_offset - offset); \ eventcode = tvb_get_guint8(next_tvb, 0); \ sent = (eventcode & 0x80) ? "Sent-" : ""; \ @@ -1273,7 +1273,7 @@ static const value_string zero_is_none_vals[] = { } \ if (length_remaining > plen) \ length_remaining = plen; \ - next_tvb = tvb_new_subset(tvb, offset, length_remaining, plen); \ + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length_remaining, plen); \ \ if (sep == NULL) { \ col_set_str(pinfo->cinfo, COL_INFO, str); \ @@ -4698,7 +4698,7 @@ static void dissect_x11_requests(tvbuff_t *tvb, packet_info *pinfo, length = length_remaining; if (length > plen) length = plen; - next_tvb = tvb_new_subset(tvb, offset, length, plen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, plen); /* * Set the column appropriately. diff --git a/epan/dissectors/packet-xip-serval.c b/epan/dissectors/packet-xip-serval.c index 5a75939e1d..01a875d570 100644 --- a/epan/dissectors/packet-xip-serval.c +++ b/epan/dissectors/packet-xip-serval.c @@ -246,13 +246,13 @@ display_xip_serval(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * size of the TCP header of 32-bit words. */ guint8 tcp_len = hi_nibble(tvb_get_guint8(tvb, offset + 12))*4; - next_tvb = tvb_new_subset(tvb, offset, tcp_len, tcp_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, tcp_len, tcp_len); call_dissector(tcp_handle, next_tvb, pinfo, tree); break; } case IP_PROTO_UDP: /* The UDP header is always 8 bytes. */ - next_tvb = tvb_new_subset(tvb, offset, 8, 8); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, 8, 8); call_dissector(udp_handle, next_tvb, pinfo, tree); break; default: diff --git a/epan/dissectors/packet-xot.c b/epan/dissectors/packet-xot.c index 6ece8f407a..c38f82be07 100644 --- a/epan/dissectors/packet-xot.c +++ b/epan/dissectors/packet-xot.c @@ -267,7 +267,7 @@ static int dissect_xot_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, hdr_offset += init_itf_name_len; proto_tree_add_item(xot_tree, hf_xot_pvc_resp_itf_name, tvb, hdr_offset, resp_itf_name_len, ENC_ASCII|ENC_NA); } else { - next_tvb = tvb_new_subset(tvb, offset, + next_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN(plen, tvb_captured_length_remaining(tvb, offset)), plen); call_dissector(x25_handle, next_tvb, pinfo, tree); } @@ -295,7 +295,7 @@ static int dissect_xot_mult(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, while (offset <= offset_max - XOT_HEADER_LENGTH){ int plen = get_xot_pdu_len(pinfo, tvb, offset, NULL); - next_tvb = tvb_new_subset(tvb, offset,plen, plen); + next_tvb = tvb_new_subset_length_caplen(tvb, offset,plen, plen); /*MIN(plen,tvb_captured_length_remaining(tvb, offset)),plen*/ dissect_xot_pdu(next_tvb, pinfo, tree, data); diff --git a/epan/dissectors/packet-zbee-nwk-gp.c b/epan/dissectors/packet-zbee-nwk-gp.c index 64f73dfe7b..112ecb4c74 100644 --- a/epan/dissectors/packet-zbee-nwk-gp.c +++ b/epan/dissectors/packet-zbee-nwk-gp.c @@ -1440,7 +1440,7 @@ dissect_zbee_nwk_gp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d add_new_data_source(pinfo, payload_tvb, "Decrypted GP Payload"); dissect_zbee_nwk_gp_cmd(payload_tvb, pinfo, nwk_tree, data); } else { - payload_tvb = tvb_new_subset(tvb, offset - packet.payload_len - packet.mic_size, packet.payload_len, -1); + payload_tvb = tvb_new_subset_length_caplen(tvb, offset - packet.payload_len - packet.mic_size, packet.payload_len, -1); call_data_dissector(payload_tvb, pinfo, tree); } } diff --git a/epan/dissectors/pidl/eventlog/eventlog.cnf b/epan/dissectors/pidl/eventlog/eventlog.cnf index 1e6690b402..f918211715 100644 --- a/epan/dissectors/pidl/eventlog/eventlog.cnf +++ b/epan/dissectors/pidl/eventlog/eventlog.cnf @@ -54,7 +54,7 @@ eventlog_dissect_element_ReadEventLogW_data_(tvbuff_t *tvb, int offset, packet_i * NDR encoded at all and there are byte offsets into this buffer * encoded therein. */ - record_tvb=tvb_new_subset(tvb, offset, MIN((gint)len, tvb_captured_length_remaining(tvb, offset)), len); + record_tvb=tvb_new_subset_length_caplen(tvb, offset, MIN((gint)len, tvb_captured_length_remaining(tvb, offset)), len); eventlog_dissect_struct_Record(record_tvb, 0, pinfo, tree, di, drep, hf_eventlog_Record, 0); offset+=len; @@ -85,7 +85,7 @@ eventlog_dissect_element_Record_sid_offset(tvbuff_t *tvb, int offset, packet_inf /* this blob contains an NT SID. * tvb starts at the beginning of the record. */ - sid_tvb=tvb_new_subset(tvb, sid_offset, MIN((gint)sid_length, tvb_captured_length_remaining(tvb, offset)), sid_length); + sid_tvb=tvb_new_subset_length_caplen(tvb, sid_offset, MIN((gint)sid_length, tvb_captured_length_remaining(tvb, offset)), sid_length); dissect_nt_sid(sid_tvb, 0, tree, "SID", NULL, -1); } diff --git a/epan/dissectors/pidl/lsa/lsa.cnf b/epan/dissectors/pidl/lsa/lsa.cnf index 01c0f56579..738476d4fb 100644 --- a/epan/dissectors/pidl/lsa/lsa.cnf +++ b/epan/dissectors/pidl/lsa/lsa.cnf @@ -383,7 +383,7 @@ lsarpc_dissect_element_lsa_DomainInfoEfs_efs_blob_(tvbuff_t *tvb _U_, int offset len = tvb_captured_length_remaining(tvb, offset); } - next_tvb = tvb_new_subset(tvb, offset, len, reported_len); + next_tvb = tvb_new_subset_length_caplen(tvb, offset, len, reported_len); efsblob_handle = find_dissector("efsblob"); if (efsblob_handle) { diff --git a/epan/dissectors/pidl/mapi/response.cnf.c b/epan/dissectors/pidl/mapi/response.cnf.c index a4f4b7e034..cefa4be7b7 100644 --- a/epan/dissectors/pidl/mapi/response.cnf.c +++ b/epan/dissectors/pidl/mapi/response.cnf.c @@ -172,7 +172,7 @@ mapi_dissect_element_EcDoRpc_response__(tvbuff_t *tvb _U_, int offset _U_, packe tvbuff_t *subtvb; length = tvb_get_letohs(tvb, offset); - subtvb = tvb_new_subset(tvb, offset, length, length); + subtvb = tvb_new_subset_length_caplen(tvb, offset, length, length); offset += 2; while (offset < length) { diff --git a/epan/tpg.h b/epan/tpg.h index d4c8dff620..645446db15 100644 --- a/epan/tpg.h +++ b/epan/tpg.h @@ -58,7 +58,7 @@ extern tpg_parser_data_t* tpg_start(proto_tree* root_tree, #define TPG_INT(i) strtol(tvb_get_string_enc(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len, ENC_ASCII),NULL,10) #define TPG_UINT(i) strtoul(tvb_get_string_enc(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len, ENC_ASCII),NULL,10) #define TPG_UINT_HEX(i) strtoul(tvb_get_string_enc(wmem_packet_scope(), (i)->tvb,(i)->offset,(i)->len, ENC_ASCII),NULL,16) -#define TPG_TVB(i) tvb_new_subset((i)->tvb,(i)->offset,(i)->len,(i)->len) +#define TPG_TVB(i) tvb_new_subset_length_caplen((i)->tvb,(i)->offset,(i)->len,(i)->len) WS_DLL_PUBLIC guint32 tpg_ipv4(tvbparse_elem_t*); #define TPG_IPV4(i) tpg_ipv4((i)) diff --git a/epan/tvbtest.c b/epan/tvbtest.c index 48f6e024ec..36ccb653ff 100644 --- a/epan/tvbtest.c +++ b/epan/tvbtest.c @@ -358,32 +358,32 @@ run_tests(void) subset_length[0] = 8; subset_reported_length[0] = 9; - tvb_subset[0] = tvb_new_subset(tvb_small[0], 0, 8, 9); + tvb_subset[0] = tvb_new_subset_length_caplen(tvb_small[0], 0, 8, 9); subset[0] = &small[0][0]; subset_length[1] = 10; subset_reported_length[1] = 11; - tvb_subset[1] = tvb_new_subset(tvb_large[0], -10, 10, 11); + tvb_subset[1] = tvb_new_subset_length_caplen(tvb_large[0], -10, 10, 11); subset[1] = &large[0][9]; subset_length[2] = 16; subset_reported_length[2] = 17; - tvb_subset[2] = tvb_new_subset(tvb_small[1], -16, -1, 17); + tvb_subset[2] = tvb_new_subset_length_caplen(tvb_small[1], -16, -1, 17); subset[2] = &small[1][0]; subset_length[3] = 3; subset_reported_length[3] = 4; - tvb_subset[3] = tvb_new_subset(tvb_subset[0], 0, 3, 4); + tvb_subset[3] = tvb_new_subset_length_caplen(tvb_subset[0], 0, 3, 4); subset[3] = &small[0][0]; subset_length[4] = 5; subset_reported_length[4] = 6; - tvb_subset[4] = tvb_new_subset(tvb_subset[1], -5, 5, 6); + tvb_subset[4] = tvb_new_subset_length_caplen(tvb_subset[1], -5, 5, 6); subset[4] = &large[0][14]; subset_length[5] = 8; subset_reported_length[5] = 9; - tvb_subset[5] = tvb_new_subset(tvb_subset[2], 4, 8, 9); + tvb_subset[5] = tvb_new_subset_length_caplen(tvb_subset[2], 4, 8, 9); subset[5] = &small[1][4]; /* Test the TVBUFF_SUBSET objects. */ diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 2ac01751b6..6bd1c4b341 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -341,7 +341,7 @@ tvb_new_octet_aligned(tvbuff_t *tvb, guint32 bit_offset, gint32 no_of_bits) /* already aligned -> shortcut */ if ((left == 0) && (remaining_bits == 0)) { - return tvb_new_subset(tvb, byte_offset, datalen, datalen); + return tvb_new_subset_length_caplen(tvb, byte_offset, datalen, datalen); } DISSECTOR_ASSERT(datalen>0); diff --git a/epan/tvbuff.h b/epan/tvbuff.h index 4ceb5a000e..1cd9c80124 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -75,7 +75,7 @@ typedef struct tvbuff tvbuff_t; * * A dissector: * - Can chain new tvbs (subset, real, composite) to the - * tvb handed to the dissector using tvb_new_subset(), + * tvb handed to the dissector using tvb_new_subset_length_caplen(), * tvb_new_subset_length(), tvb_new_subset_remaining(), * tvb_new_child_real_data(), tvb_set_child_real_data_tvbuff(), * tvb_composite_finalize(), and tvb_child_uncompress(). (Composite @@ -185,19 +185,19 @@ WS_DLL_PUBLIC tvbuff_t *tvb_new_real_data(const guint8 *data, * Will throw BoundsError if 'backing_offset'/'length' * is beyond the bounds of the backing tvbuff. * Can throw ReportedBoundsError. */ -WS_DLL_PUBLIC tvbuff_t *tvb_new_subset(tvbuff_t *backing, +WS_DLL_PUBLIC tvbuff_t *tvb_new_subset_length_caplen(tvbuff_t *backing, const gint backing_offset, const gint backing_length, const gint reported_length); /** - * Similar to tvb_new_subset() but with captured length calculated + * Similar to tvb_new_subset_length_caplen() but with captured length calculated * to fit within the existing captured length and the specified * backing length (which is used as the reported length). * Can throw ReportedBoundsError. */ WS_DLL_PUBLIC tvbuff_t *tvb_new_subset_length(tvbuff_t *backing, const gint backing_offset, const gint backing_length); -/** Similar to tvb_new_subset() but with backing_length and reported_length set +/** Similar to tvb_new_subset_length_caplen() but with backing_length and reported_length set * to -1. Can throw ReportedBoundsError. */ WS_DLL_PUBLIC tvbuff_t *tvb_new_subset_remaining(tvbuff_t *backing, const gint backing_offset); diff --git a/epan/tvbuff_subset.c b/epan/tvbuff_subset.c index b463e46b0f..3e4bab06b0 100644 --- a/epan/tvbuff_subset.c +++ b/epan/tvbuff_subset.c @@ -144,7 +144,7 @@ tvb_new_with_subset(tvbuff_t *backing, const gint reported_length, } tvbuff_t * -tvb_new_subset(tvbuff_t *backing, const gint backing_offset, const gint backing_length, const gint reported_length) +tvb_new_subset_length_caplen(tvbuff_t *backing, const gint backing_offset, const gint backing_length, const gint reported_length) { tvbuff_t *tvb; guint subset_tvb_offset; diff --git a/epan/wslua/wslua_tvb.c b/epan/wslua/wslua_tvb.c index 33ffa65ddc..d1819b70a8 100644 --- a/epan/wslua/wslua_tvb.c +++ b/epan/wslua/wslua_tvb.c @@ -407,7 +407,7 @@ WSLUA_METHOD TvbRange_tvb(lua_State *L) { tvb = (Tvb)g_malloc(sizeof(struct _wslua_tvb)); tvb->expired = FALSE; tvb->need_free = FALSE; - tvb->ws_tvb = tvb_new_subset(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len, tvbr->len); + tvb->ws_tvb = tvb_new_subset_length_caplen(tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len, tvbr->len); return push_wsluaTvb(L, tvb); } else { luaL_error(L,"Out Of Bounds"); diff --git a/plugins/docsis/packet-docsis.c b/plugins/docsis/packet-docsis.c index e8bfd9d067..01f44c384b 100644 --- a/plugins/docsis/packet-docsis.c +++ b/plugins/docsis/packet-docsis.c @@ -778,7 +778,7 @@ dissect_docsis (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da call_dissector (eth_withoutfcs_handle, next_tvb, pinfo, docsis_tree); } else { /* Otherwise treat as Data */ - tvbuff_t *payload_tvb = tvb_new_subset(tvb, hdrlen, (len_sid - 4), -1); + tvbuff_t *payload_tvb = tvb_new_subset_length_caplen(tvb, hdrlen, (len_sid - 4), -1); call_data_dissector(payload_tvb, pinfo, docsis_tree); } } else { @@ -832,7 +832,7 @@ dissect_docsis (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* da * docsis frames are dissected. */ while (concatlen > 0) { - next_tvb = tvb_new_subset (tvb, concatpos, -1, concatlen); + next_tvb = tvb_new_subset_length_caplen (tvb, concatpos, -1, concatlen); call_dissector (docsis_handle, next_tvb, pinfo, docsis_tree); } concatlen = 0; diff --git a/plugins/irda/packet-sir.c b/plugins/irda/packet-sir.c index 9060e42ece..54457069e0 100644 --- a/plugins/irda/packet-sir.c +++ b/plugins/irda/packet-sir.c @@ -140,7 +140,7 @@ dissect_sir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root, void* data _U_) } else { guint preamble_len = bof_offset - offset; gint data_offset = bof_offset + 1; - tvbuff_t* next_tvb = tvb_new_subset(tvb, + tvbuff_t* next_tvb = tvb_new_subset_length_caplen(tvb, data_offset, eof_offset - data_offset, -1); next_tvb = unescape_data(next_tvb, pinfo); if (root) { diff --git a/plugins/wimaxasncp/packet-wimaxasncp.c b/plugins/wimaxasncp/packet-wimaxasncp.c index 27d06c81e8..c5c19f391d 100644 --- a/plugins/wimaxasncp/packet-wimaxasncp.c +++ b/plugins/wimaxasncp/packet-wimaxasncp.c @@ -1887,7 +1887,7 @@ static guint dissect_wimaxasncp_tlvs( tvbuff_t *tlv_tvb; /* N.B. Not padding out tvb length */ - tlv_tvb = tvb_new_subset( + tlv_tvb = tvb_new_subset_length_caplen( tvb, offset, MIN(length, tvb_captured_length_remaining(tvb, offset)), length); @@ -1907,7 +1907,7 @@ static guint dissect_wimaxasncp_tlvs( tvb_ensure_bytes_exist(tvb, offset, length + pad); - tlv_tvb = tvb_new_subset( + tlv_tvb = tvb_new_subset_length_caplen( tvb, offset, MIN(length, tvb_captured_length_remaining(tvb, offset)), length); @@ -2389,7 +2389,7 @@ dissect_wimaxasncp( * ------------------------------------------------------------------------ */ - subtree = tvb_new_subset( + subtree = tvb_new_subset_length_caplen( tvb, offset, MIN(length, tvb_captured_length_remaining(tvb, offset)), length - WIMAXASNCP_HEADER_LENGTH_END); diff --git a/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index 2b2683f2fa..41d788ffce 100644 --- a/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -420,7 +420,7 @@ sub ElementLevel($$$$$$$$) # continue to dissect handmarshalled stuff with pidl $self->pidl_code("di->call_data->flags &= ~DCERPC_IS_NDR64;"); - $self->pidl_code("subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1);"); + $self->pidl_code("subtvb = tvb_new_subset_length_caplen(tvb, offset, (const gint)size, -1);"); if ($param ne 0) { $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, di, drep, $param);"); } else {