From 6ce6394a26aa87eb0b4b95ecd4725ef817a52612 Mon Sep 17 00:00:00 2001 From: stig Date: Tue, 19 May 2009 17:16:14 +0000 Subject: From Artem Tamazov (bug 3472): Save/Restore pinfo->private_data when used. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28412 f5534014-38df-0310-8fa8-9805f1628bb7 --- epan/dissectors/packet-aim.c | 3 +++ epan/dissectors/packet-atalk.c | 3 +++ epan/dissectors/packet-bthci_acl.c | 4 ++++ epan/dissectors/packet-btl2cap.c | 3 +++ epan/dissectors/packet-dsi.c | 3 +++ epan/dissectors/packet-fcsb3.c | 3 +++ epan/dissectors/packet-gsm_a_dtap.c | 1 + epan/dissectors/packet-gtp.c | 7 +++++-- epan/dissectors/packet-http.c | 4 +++- epan/dissectors/packet-ieee802154.c | 5 +++++ epan/dissectors/packet-imf.c | 4 +++- epan/dissectors/packet-ipx.c | 9 +++++++++ epan/dissectors/packet-isakmp.c | 9 +++++++++ epan/dissectors/packet-mq.c | 3 +++ epan/dissectors/packet-mtp3.c | 8 ++++++-- epan/dissectors/packet-rx.c | 3 +++ 16 files changed, 66 insertions(+), 6 deletions(-) (limited to 'epan/dissectors') diff --git a/epan/dissectors/packet-aim.c b/epan/dissectors/packet-aim.c index 3c9d90c6be..d0c7ec72f7 100644 --- a/epan/dissectors/packet-aim.c +++ b/epan/dissectors/packet-aim.c @@ -791,6 +791,7 @@ static void dissect_aim_snac(tvbuff_t *tvb, packet_info *pinfo, const aim_subtype *subtype; proto_tree *family_tree = NULL; const aim_family *family; + void* pd_save; orig_offset = offset; family_id = tvb_get_ntohs(tvb, offset); @@ -846,6 +847,7 @@ static void dissect_aim_snac(tvbuff_t *tvb, packet_info *pinfo, aiminfo.tcpinfo = pinfo->private_data; aiminfo.family = family_id; aiminfo.subtype = subtype_id; + pd_save = pinfo->private_data; pinfo->private_data = &aiminfo; if (check_col(pinfo->cinfo, COL_PROTOCOL) && family) { @@ -876,6 +878,7 @@ static void dissect_aim_snac(tvbuff_t *tvb, packet_info *pinfo, if(tvb_length_remaining(tvb, offset) > 0 && subtype && subtype->dissector) { subtype->dissector(subtvb, pinfo, family_tree); } + pinfo->private_data = pd_save; } static void dissect_aim_flap_err(tvbuff_t *tvb, packet_info *pinfo, diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c index 70c06041c4..f3b0f2eff8 100644 --- a/epan/dissectors/packet-atalk.c +++ b/epan/dissectors/packet-atalk.c @@ -918,6 +918,8 @@ dissect_atp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { } if (new_tvb) { + void* pd_save; + pd_save = pinfo->private_data; pinfo->private_data = &aspinfo; /* if port == 6 it's not an ASP packet but a ZIP packet */ if (pinfo->srcport == 6 || pinfo->destport == 6 ) @@ -950,6 +952,7 @@ dissect_atp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { } } + pinfo->private_data = pd_save; } else { /* Just show this as a fragment. */ diff --git a/epan/dissectors/packet-bthci_acl.c b/epan/dissectors/packet-bthci_acl.c index 2cc0eb4fee..38e55f9a36 100644 --- a/epan/dissectors/packet-bthci_acl.c +++ b/epan/dissectors/packet-bthci_acl.c @@ -100,6 +100,7 @@ dissect_btacl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvbuff_t *next_tvb; bthci_acl_data_t *acl_data; chandle_data_t *chandle_data; + void* pd_save; if(check_col(pinfo->cinfo, COL_PROTOCOL)){ col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI_ACL"); @@ -119,6 +120,7 @@ dissect_btacl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) acl_data=ep_alloc(sizeof(bthci_acl_data_t)); acl_data->chandle=flags&0x0fff; + pd_save = pinfo->private_data; pinfo->private_data=acl_data; /* find the chandle_data structure associated with this chandle */ @@ -157,6 +159,7 @@ dissect_btacl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if(btl2cap_handle){ call_dissector(btl2cap_handle, next_tvb, pinfo, tree); } + pinfo->private_data = pd_save; return; } @@ -220,6 +223,7 @@ dissect_btacl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } } + pinfo->private_data = pd_save; } diff --git a/epan/dissectors/packet-btl2cap.c b/epan/dissectors/packet-btl2cap.c index 45144cbd6a..80c9236e31 100644 --- a/epan/dissectors/packet-btl2cap.c +++ b/epan/dissectors/packet-btl2cap.c @@ -787,6 +787,7 @@ static void dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) bthci_acl_data_t *acl_data; btl2cap_data_t *l2cap_data; config_data_t *config_data; + void* pd_save; if(check_col(pinfo->cinfo, COL_PROTOCOL)){ col_set_str(pinfo->cinfo, COL_PROTOCOL, "L2CAP"); @@ -813,6 +814,7 @@ static void dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) l2cap_data=ep_alloc(sizeof(btl2cap_data_t)); l2cap_data->chandle=acl_data->chandle; l2cap_data->cid=cid; + pd_save = pinfo->private_data; pinfo->private_data=l2cap_data; if(cid==0x0001){ /* This is a command packet*/ @@ -984,6 +986,7 @@ static void dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(btl2cap_tree, hf_btl2cap_payload, tvb, offset, length, TRUE); offset+=length; } + pinfo->private_data = pd_save; } diff --git a/epan/dissectors/packet-dsi.c b/epan/dissectors/packet-dsi.c index 9512c02bf5..9e1c5afb7e 100644 --- a/epan/dissectors/packet-dsi.c +++ b/epan/dissectors/packet-dsi.c @@ -569,17 +569,20 @@ dissect_dsi_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case DSIFUNC_WRITE: { tvbuff_t *new_tvb; + void* pd_save; int len = tvb_reported_length_remaining(tvb,DSI_BLOCKSIZ); aspinfo.reply = (dsi_flags == DSIFL_REPLY); aspinfo.command = dsi_command; aspinfo.seq = dsi_requestid; aspinfo.code = dsi_code; + pd_save = pinfo->private_data; pinfo->private_data = &aspinfo; proto_item_set_len(dsi_tree, DSI_BLOCKSIZ); new_tvb = tvb_new_subset(tvb, DSI_BLOCKSIZ,-1,len); call_dissector(afp_handle, new_tvb, pinfo, tree); + pinfo->private_data = pd_save; } break; default: diff --git a/epan/dissectors/packet-fcsb3.c b/epan/dissectors/packet-fcsb3.c index 2ae1e84f51..d26cbf7d59 100644 --- a/epan/dissectors/packet-fcsb3.c +++ b/epan/dissectors/packet-fcsb3.c @@ -1016,6 +1016,7 @@ static void dissect_fc_sbccs (tvbuff_t *tvb, packet_info *pinfo, tvbuff_t *next_tvb; conversation_t *conversation; sb3_task_id_t task_key; + void* pd_save; /* Make entries in Protocol column and Info column on summary display */ if (check_col(pinfo->cinfo, COL_PROTOCOL)) @@ -1034,6 +1035,7 @@ static void dissect_fc_sbccs (tvbuff_t *tvb, packet_info *pinfo, conversation = find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_SBCCS, ch_cu_id, dev_addr, 0); + pd_save = pinfo->private_data; if (conversation) { task_key.conv_id = conversation->index; task_key.task_id = ccw; @@ -1097,6 +1099,7 @@ static void dissect_fc_sbccs (tvbuff_t *tvb, packet_info *pinfo, -1, -1); call_dissector (data_handle, next_tvb, pinfo, tree); } + pinfo->private_data = pd_save; } /* Register the protocol with Wireshark */ diff --git a/epan/dissectors/packet-gsm_a_dtap.c b/epan/dissectors/packet-gsm_a_dtap.c index c16fc603a5..47aaa13686 100644 --- a/epan/dissectors/packet-gsm_a_dtap.c +++ b/epan/dissectors/packet-gsm_a_dtap.c @@ -2685,6 +2685,7 @@ de_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint fac_len, gcha if (ind){ proto_tree_add_text(tree, tvb, offset+1, 1, "Indefinte length, ignoring component"); + gsm_a_dtap_pinfo->private_data = save_private_data; return (fac_len); } header_len = header_end_offset - offset; diff --git a/epan/dissectors/packet-gtp.c b/epan/dissectors/packet-gtp.c index bf24323e25..d6a4cac81f 100644 --- a/epan/dissectors/packet-gtp.c +++ b/epan/dissectors/packet-gtp.c @@ -6286,8 +6286,9 @@ static void dissect_gtp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) tvbuff_t *next_tvb; guint8 sub_proto, acfield_len = 0, control_field; gtp_msg_hash_t *gcrp=NULL; - conversation_t *conversation=NULL; + conversation_t *conversation=NULL; gtp_conv_info_t *gtp_info=(gtp_conv_info_t *)pinfo->private_data; + void* pd_save; /* * If this is GTPv2-C call the gtpv2 dissector if present @@ -6337,6 +6338,7 @@ static void dissect_gtp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) gtp_info->next = gtp_info_items; gtp_info_items = gtp_info; } + pd_save = pinfo->private_data; pinfo->private_data = gtp_info; tvb_memcpy(tvb, (guint8 *) & gtp_hdr, 0, 4); @@ -6372,6 +6374,7 @@ static void dissect_gtp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) if(version>=2){ proto_tree_add_text(tree, tvb, 0, -1, "No WS dissector for GTP version %u %s", version, val_to_str(version, ver_types, "Unknown")); + pinfo->private_data = pd_save; return; } @@ -6583,7 +6586,7 @@ static void dissect_gtp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) col_append_str(pinfo->cinfo, COL_PROTOCOL, ">"); } } - + pinfo->private_data = pd_save; } static const true_false_string yes_no_tfs = { diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index 5752a1fa12..c05230584c 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -1005,6 +1005,7 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo, */ tvbuff_t *next_tvb; void *save_private_data = NULL; + gboolean private_data_changed = FALSE; gint chunks_decoded = 0; /* @@ -1175,6 +1176,7 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo, * for that content type? */ save_private_data = pinfo->private_data; + private_data_changed = TRUE; if (headers.content_type_parameters) pinfo->private_data = ep_strdup(headers.content_type_parameters); @@ -1230,7 +1232,7 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo, * Do *not* attempt at freeing the private data; * it may be in use by subdissectors. */ - if (save_private_data) + if (private_data_changed) /*restore even NULL value*/ pinfo->private_data = save_private_data; /* * We've processed "datalen" bytes worth of data diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c index 98743c3cee..bbb007ea67 100644 --- a/epan/dissectors/packet-ieee802154.c +++ b/epan/dissectors/packet-ieee802154.c @@ -567,6 +567,7 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g proto_tree *volatile ieee802154_tree = NULL; proto_item *volatile proto_root = NULL; proto_item *ti; + void *pd_save; guint offset = 0; volatile gboolean fcs_ok = TRUE; @@ -575,6 +576,7 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g /* Link our packet info structure into the private data field for the * Network-Layer heuristic subdissectors. */ + pd_save = pinfo->private_data; pinfo->private_data = packet; /* Create the protocol tree. */ @@ -690,6 +692,7 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g else if (packet->dst_addr_mode != IEEE802154_FCF_ADDR_NONE) { /* Invalid Destination Address Mode. Abort Dissection. */ expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_ERROR, "Invalid Destination Address Mode"); + pinfo->private_data = pd_save; return; } @@ -769,6 +772,7 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g else if (packet->src_addr_mode != IEEE802154_FCF_ADDR_NONE) { /* Invalid Destination Address Mode. Abort Dissection. */ expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_ERROR, "Invalid Source Address Mode"); + pinfo->private_data = pd_save; return; } @@ -918,6 +922,7 @@ dissect_ieee802154_fcs: /* Flag packet as having a bad crc. */ expert_add_info_format(pinfo, proto_root, PI_CHECKSUM, PI_WARN, "Bad FCS"); } + pinfo->private_data = pd_save; } /* dissect_ieee802154_common */ /*FUNCTION:------------------------------------------------------ diff --git a/epan/dissectors/packet-imf.c b/epan/dissectors/packet-imf.c index 1448a1ebb6..3facbed747 100644 --- a/epan/dissectors/packet-imf.c +++ b/epan/dissectors/packet-imf.c @@ -596,13 +596,15 @@ static void dissect_imf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* now dissect the MIME based upon the content type */ if(content_type_str && media_type_dissector_table) { - + void* pd_save; + pd_save = pinfo->private_data; pinfo->private_data = parameters; next_tvb = tvb_new_subset(tvb, end_offset, -1, -1); dissected = dissector_try_string(media_type_dissector_table, content_type_str, next_tvb, pinfo, tree); + pinfo->private_data = pd_save; } else { /* just show the lines or highlight the rest of the buffer as message text */ diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index 89d2302db5..1ce2f0a337 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -787,6 +787,7 @@ dissect_spx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tvb_reported_length_remaining(tvb, SPX_HEADER_LEN) > 0) { + void* pd_save; /* * Call subdissectors based on the IPX socket numbers; a * subdissector might have registered with our IPX socket @@ -815,16 +816,24 @@ dissect_spx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ spx_info.eom = conn_ctrl & SPX_EOM; spx_info.datastream_type = datastream_type; + pd_save = pinfo->private_data; pinfo->private_data = &spx_info; next_tvb = tvb_new_subset(tvb, SPX_HEADER_LEN, -1, -1); if (dissector_try_port(spx_socket_dissector_table, low_socket, next_tvb, pinfo, tree)) + { + pinfo->private_data = pd_save; return; + } if (dissector_try_port(spx_socket_dissector_table, high_socket, next_tvb, pinfo, tree)) + { + pinfo->private_data = pd_save; return; + } call_dissector(data_handle, next_tvb, pinfo, tree); + pinfo->private_data = pd_save; } } diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index fe4b6d0223..7ed5fbfdc9 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -1000,6 +1000,8 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvbuff_t *decr_tvb; proto_tree *decr_tree; address null_addr; + void *pd_save; + gboolean pd_changed = FALSE; #endif /* HAVE_LIBGCRYPT */ if (check_col(pinfo->cinfo, COL_PROTOCOL)) @@ -1055,7 +1057,9 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) SE_COPY_ADDRESS(&decr->initiator, &pinfo->src); } + pd_save = pinfo->private_data; pinfo->private_data = decr; + pd_changed = TRUE; } else if (isakmp_version == 2) { ikev2_uat_data_key_t hash_key; ikev2_uat_data_t *ike_sa_data = NULL; @@ -1079,7 +1083,9 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ikev2_dec_data->encr_spec = ike_sa_data->encr_spec; ikev2_dec_data->auth_spec = ike_sa_data->auth_spec; + pd_save = pinfo->private_data; pinfo->private_data = ikev2_dec_data; + pd_changed = TRUE; } } #endif /* HAVE_LIBGCRYPT */ @@ -1151,6 +1157,7 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint_format(isakmp_tree, hf_isakmp_length, tvb, offset, sizeof(hdr.length), hdr.length, "Length: (bogus, length is %u, should be at least %lu)", hdr.length, (unsigned long)ISAKMP_HDR_SIZE); + if (pd_changed) pinfo->private_data = pd_save; return; } @@ -1160,6 +1167,7 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint_format(isakmp_tree, hf_isakmp_length, tvb, offset, sizeof(hdr.length), hdr.length, "Length: (bogus, length is %u, which is too large)", hdr.length); + if (pd_changed) pinfo->private_data = pd_save; return; } @@ -1187,6 +1195,7 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) dissect_payloads(tvb, isakmp_tree, tree, isakmp_version, hdr.next_payload, offset, len, pinfo); } + if (pd_changed) pinfo->private_data = pd_save; } static proto_tree * diff --git a/epan/dissectors/packet-mq.c b/epan/dissectors/packet-mq.c index a891f04d23..a197968de3 100644 --- a/epan/dissectors/packet-mq.c +++ b/epan/dissectors/packet-mq.c @@ -2260,15 +2260,18 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Call subdissector for the payload */ tvbuff_t* next_tvb = NULL; + void* pd_save; struct mqinfo mqinfo; /* Format, encoding and character set are "data type" information, not subprotocol information */ mqinfo.encoding = tvb_get_guint32_endian(tvb, tMsgProps.iOffsetEncoding, bLittleEndian); mqinfo.ccsid = tvb_get_guint32_endian(tvb, tMsgProps.iOffsetCcsid, bLittleEndian); tvb_memcpy(tvb, mqinfo.format, tMsgProps.iOffsetFormat, 8); + pd_save = pinfo->private_data; pinfo->private_data = &mqinfo; next_tvb = tvb_new_subset(tvb, offset, -1, -1); if (!dissector_try_heuristic(mq_heur_subdissector_list, next_tvb, pinfo, tree)) call_dissector(data_handle, next_tvb, pinfo, tree); + pinfo->private_data = pd_save; } } offset = tvb_length(tvb); diff --git a/epan/dissectors/packet-mtp3.c b/epan/dissectors/packet-mtp3.c index 3a59049dfa..51f631ef2f 100644 --- a/epan/dissectors/packet-mtp3.c +++ b/epan/dissectors/packet-mtp3.c @@ -440,7 +440,7 @@ dissect_mtp3_3byte_pc(tvbuff_t *tvb, guint offset, proto_tree *tree, gint ett_pc } static void -dissect_mtp3_sio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mtp3_tree) +dissect_mtp3_sio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mtp3_tree, void ** const pd_save) { guint8 sio; proto_item *sio_item; @@ -477,6 +477,8 @@ dissect_mtp3_sio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mtp3_tree) proto_tree_add_uint(sio_tree, hf_mtp3_service_indicator, tvb, SIO_OFFSET, SIO_LENGTH, sio); /* Store the SI so that subidissectors know what SI this msg is */ + assert(NULL != pd_save); + *pd_save = pinfo->private_data; pinfo->private_data = GUINT_TO_POINTER(sio & SERVICE_INDICATOR_MASK); } @@ -636,6 +638,7 @@ dissect_mtp3_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) static void dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { + void* pd_save; mtp3_tap_rec_t* tap_rec = ep_alloc0(sizeof(mtp3_tap_rec_t)); /* Set up structures needed to add the protocol subtree and manage it */ @@ -682,7 +685,7 @@ dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Dissect the packet (even if !tree so can call sub-dissectors and update * the source and destination address columns) */ - dissect_mtp3_sio(tvb, pinfo, mtp3_tree); + dissect_mtp3_sio(tvb, pinfo, mtp3_tree, &pd_save); dissect_mtp3_routing_label(tvb, pinfo, mtp3_tree); memcpy(&(tap_rec->addr_opc),mtp3_addr_opc,sizeof(mtp3_addr_pc_t)); @@ -694,6 +697,7 @@ dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tap_queue_packet(mtp3_tap, pinfo, tap_rec); dissect_mtp3_payload(tvb, pinfo, tree); + pinfo->private_data = pd_save; } void diff --git a/epan/dissectors/packet-rx.c b/epan/dissectors/packet-rx.c index 483f88bf90..b92e71e3d1 100644 --- a/epan/dissectors/packet-rx.c +++ b/epan/dissectors/packet-rx.c @@ -579,9 +579,12 @@ dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) break; case RX_PACKET_TYPE_DATA: { tvbuff_t *next_tvb; + void* pd_save; + pd_save = pinfo->private_data; pinfo->private_data = &rxinfo; next_tvb = tvb_new_subset(tvb, offset, -1, -1); call_dissector(afs_handle, next_tvb, pinfo, parent_tree); + pinfo->private_data = pd_save; }; break; case RX_PACKET_TYPE_ABORT: -- cgit v1.2.3