diff options
author | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-09-06 04:26:50 +0000 |
---|---|---|
committer | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-09-06 04:26:50 +0000 |
commit | 6fe1060cd1a85736dc60de3790eb03ed7f693cd8 (patch) | |
tree | cc0942b4f55f153eea4d3d951068ee42953a8de9 /epan | |
parent | a9e644f382bbe6d7524da3374f31217c9f395f91 (diff) |
Don't pass ep_alloc()'ed strings to col_set_str().
Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3984
svn path=/trunk/; revision=29726
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-camel.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-catapult-dct2000.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-cmp.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-dlm3.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-gsm_map.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-hip.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee802154.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-mtp2.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-nat-pmp.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-ptp.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-rpl.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-smrse.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-wow.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-aps.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-nwk.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-zdp.c | 2 | ||||
-rw-r--r-- | epan/value_string.c | 16 | ||||
-rw-r--r-- | epan/value_string.h | 5 |
18 files changed, 40 insertions, 19 deletions
diff --git a/epan/dissectors/packet-camel.c b/epan/dissectors/packet-camel.c index 6a7cc6b4ec..a3e55cb7d5 100644 --- a/epan/dissectors/packet-camel.c +++ b/epan/dissectors/packet-camel.c @@ -7102,7 +7102,7 @@ dissect_camel_camelPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn if (check_col(actx->pinfo->cinfo, COL_INFO)){ /* Populate the info column with PDU type*/ - col_set_str(actx->pinfo->cinfo, COL_INFO, val_to_str(camel_pdu_type, camel_Component_vals, "Unknown Camel (%u)")); + col_add_fstr(actx->pinfo->cinfo, COL_INFO, val_to_str(camel_pdu_type, camel_Component_vals, "Unknown Camel (%u)")); col_append_str(actx->pinfo->cinfo, COL_INFO, " "); } diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c index 94f2ae7911..c5d702472d 100644 --- a/epan/dissectors/packet-catapult-dct2000.c +++ b/epan/dissectors/packet-catapult-dct2000.c @@ -794,7 +794,7 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, gint offset, } offset++; - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(opcode, rlc_op_vals, "Unknown")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(opcode, rlc_op_vals, "Unknown")); /* Assume UE side, so REQ is UL, IND is DL */ switch (opcode) { diff --git a/epan/dissectors/packet-cmp.c b/epan/dissectors/packet-cmp.c index a18960facc..50f44b88b2 100644 --- a/epan/dissectors/packet-cmp.c +++ b/epan/dissectors/packet-cmp.c @@ -1544,7 +1544,7 @@ static int dissect_cmp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa } if (check_col (pinfo->cinfo, COL_INFO)) { - col_set_str (pinfo->cinfo, COL_INFO, val_to_str (pdu_type, cmp_pdu_types, "0x%x")); + col_add_fstr (pinfo->cinfo, COL_INFO, val_to_str (pdu_type, cmp_pdu_types, "0x%x")); } switch(pdu_type){ diff --git a/epan/dissectors/packet-dlm3.c b/epan/dissectors/packet-dlm3.c index 9c6b584a0d..1398e740a2 100644 --- a/epan/dissectors/packet-dlm3.c +++ b/epan/dissectors/packet-dlm3.c @@ -784,7 +784,7 @@ dissect_dlm3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, - val_to_str(h_cmd, + val_to_str_const(h_cmd, dlm3_cmd, "packet-dlm3.c internal bug")); diff --git a/epan/dissectors/packet-gsm_map.c b/epan/dissectors/packet-gsm_map.c index b16ea58b35..9deb780143 100644 --- a/epan/dissectors/packet-gsm_map.c +++ b/epan/dissectors/packet-gsm_map.c @@ -17569,7 +17569,7 @@ dissect_gsm_map_GSMMAPPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, gsm_map_pdu_size = tvb_get_guint8(tvb, offset+1)+2; if (check_col(actx->pinfo->cinfo, COL_INFO)){ - col_set_str(actx->pinfo->cinfo, COL_INFO, val_to_str(gsmmap_pdu_type, gsm_old_Component_vals, "Unknown GSM-MAP PDU (%u)")); + col_add_fstr(actx->pinfo->cinfo, COL_INFO, val_to_str(gsmmap_pdu_type, gsm_old_Component_vals, "Unknown GSM-MAP PDU (%u)")); col_append_fstr(actx->pinfo->cinfo, COL_INFO, " "); } offset = dissect_gsm_old_Component(FALSE, tvb, 0, actx, tree, hf_gsm_map_old_Component_PDU); diff --git a/epan/dissectors/packet-hip.c b/epan/dissectors/packet-hip.c index dbb3cb726c..9ad771e464 100644 --- a/epan/dissectors/packet-hip.c +++ b/epan/dissectors/packet-hip.c @@ -435,7 +435,7 @@ dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) control_h = tvb_get_ntohs(tvb, newoffset); newoffset += 2; - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(hiph_packet_type, pinfo_vals, "Unknown")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(hiph_packet_type, pinfo_vals, "Unknown")); /* populate a tree in the second pane with the status of the link layer (i.e. none) */ if(tree) { diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c index 1ccc32cc0c..26388faf30 100644 --- a/epan/dissectors/packet-ieee802154.c +++ b/epan/dissectors/packet-ieee802154.c @@ -366,7 +366,7 @@ dissect_ieee802154_fcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ieee /* Display the frame type. */ if (tree) proto_item_append_text(tree, " %s", val_to_str(packet->frame_type, ieee802154_frame_types, "Reserved")); - if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, val_to_str(packet->frame_type, ieee802154_frame_types, "Reserved")); + if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(packet->frame_type, ieee802154_frame_types, "Reserved")); /* Add the FCF to the protocol tree. */ if (tree) { @@ -1117,7 +1117,7 @@ dissect_ieee802154_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ieee /* Get and display the command frame identifier. */ cmd_id = tvb_get_guint8(tvb, offset); if(check_col(pinfo->cinfo, COL_INFO)) { - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(cmd_id, ieee802154_cmd_names, "Unknown Command")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cmd_id, ieee802154_cmd_names, "Unknown Command")); } if (tree) { /* Create a subtree for this command frame. */ diff --git a/epan/dissectors/packet-mtp2.c b/epan/dissectors/packet-mtp2.c index cb3c4728ca..6f0810aabc 100644 --- a/epan/dissectors/packet-mtp2.c +++ b/epan/dissectors/packet-mtp2.c @@ -269,7 +269,7 @@ dissect_mtp2_lssu(tvbuff_t *su_tvb, packet_info *pinfo, proto_item *mtp2_tree) proto_tree_add_item(mtp2_tree, hf_mtp2_sf_extra, su_tvb, sf_extra_offset, SF_EXTRA_LENGTH, LITTLE_ENDIAN_BYTE_ORDER); if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(sf, status_field_acro_vals, "Unknown")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(sf, status_field_acro_vals, "Unknown")); } static void diff --git a/epan/dissectors/packet-nat-pmp.c b/epan/dissectors/packet-nat-pmp.c index 74305f947e..0dfd2e8570 100644 --- a/epan/dissectors/packet-nat-pmp.c +++ b/epan/dissectors/packet-nat-pmp.c @@ -105,7 +105,7 @@ static void dissect_nat_pmp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree op_ti = proto_tree_add_item (nat_pmp_tree, hf_opcode, tvb, offset, 1, FALSE); offset++; - col_set_str (pinfo->cinfo, COL_INFO, val_to_str (opcode, opcode_vals, "Unknown opcode: %d")); + col_add_fstr (pinfo->cinfo, COL_INFO, val_to_str (opcode, opcode_vals, "Unknown opcode: %d")); switch (opcode) { diff --git a/epan/dissectors/packet-ptp.c b/epan/dissectors/packet-ptp.c index f78bb64c58..9200c36702 100644 --- a/epan/dissectors/packet-ptp.c +++ b/epan/dissectors/packet-ptp.c @@ -2258,13 +2258,13 @@ dissect_ptp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ptp2_managementErrorId_vals, "Unknown Error Id %u")); break; default: - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(ptp_v2_messageid, ptp_v2_messageid_vals, "Unknown PTP Message (%u)")); + col_add_fstr(pinfo->cinfo, COL_INFO, val_to_str(ptp_v2_messageid, ptp_v2_messageid_vals, "Unknown PTP Message (%u)")); break; } } else { - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(ptp_v2_messageid, ptp_v2_messageid_vals, "Unknown PTP Message (%u)")); + col_add_fstr(pinfo->cinfo, COL_INFO, val_to_str(ptp_v2_messageid, ptp_v2_messageid_vals, "Unknown PTP Message (%u)")); } } diff --git a/epan/dissectors/packet-rpl.c b/epan/dissectors/packet-rpl.c index fd04576c6a..bbb5723756 100644 --- a/epan/dissectors/packet-rpl.c +++ b/epan/dissectors/packet-rpl.c @@ -277,7 +277,7 @@ dissect_rpl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->cinfo, COL_INFO)) { col_set_str(pinfo->cinfo, COL_INFO, - val_to_str(rpl_type, rpl_type_vals, "Unknown Type")); + val_to_str_const(rpl_type, rpl_type_vals, "Unknown Type")); } if (tree) { ti = proto_tree_add_item(tree, proto_rpl, tvb, 0, diff --git a/epan/dissectors/packet-smrse.c b/epan/dissectors/packet-smrse.c index 4555ae8627..cba121d3ca 100644 --- a/epan/dissectors/packet-smrse.c +++ b/epan/dissectors/packet-smrse.c @@ -528,7 +528,7 @@ dissect_smrse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMRSE"); if (check_col(pinfo->cinfo, COL_INFO)) - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(tag, tag_vals,"Unknown Tag:0x%02x")); + col_add_fstr(pinfo->cinfo, COL_INFO, val_to_str(tag, tag_vals,"Unknown Tag:0x%02x")); proto_tree_add_item(tree, hf_smrse_reserved, tvb, 0, 1, FALSE); proto_tree_add_item(tree, hf_smrse_length, tvb, 1, 2, FALSE); diff --git a/epan/dissectors/packet-wow.c b/epan/dissectors/packet-wow.c index 45736b0696..4660276b2b 100644 --- a/epan/dissectors/packet-wow.c +++ b/epan/dissectors/packet-wow.c @@ -213,7 +213,7 @@ dissect_wow_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if(check_col(pinfo->cinfo, COL_INFO)) { col_set_str(pinfo->cinfo, COL_INFO, - val_to_str(cmd, cmd_vs, + val_to_str_const(cmd, cmd_vs, "Unrecognized packet type")); } diff --git a/epan/dissectors/packet-zbee-aps.c b/epan/dissectors/packet-zbee-aps.c index 0d9a569f91..e764d329e9 100644 --- a/epan/dissectors/packet-zbee-aps.c +++ b/epan/dissectors/packet-zbee-aps.c @@ -965,7 +965,7 @@ static void dissect_zbee_aps_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree * /* Add the command name to the info column. */ if (check_col(pinfo->cinfo, COL_INFO)) { - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(cmd_id, zbee_aps_cmd_names, "Unknown Command")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cmd_id, zbee_aps_cmd_names, "Unknown Command")); } /* Handle the contents of the command frame. */ diff --git a/epan/dissectors/packet-zbee-nwk.c b/epan/dissectors/packet-zbee-nwk.c index 2faf932647..6d675736eb 100644 --- a/epan/dissectors/packet-zbee-nwk.c +++ b/epan/dissectors/packet-zbee-nwk.c @@ -414,7 +414,7 @@ dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item_append_text(proto_root, " %s", val_to_str(packet.type, zbee_nwk_frame_types, "Unknown Type")); } if (check_col(pinfo->cinfo, COL_INFO)) { - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(packet.type, zbee_nwk_frame_types, "Reserved Frame Type")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(packet.type, zbee_nwk_frame_types, "Reserved Frame Type")); } /* Get the destination address. */ @@ -641,7 +641,7 @@ static void dissect_zbee_nwk_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree * /* Add the command name to the info column. */ if (check_col(pinfo->cinfo, COL_INFO)) { - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(cmd_id, zbee_nwk_cmd_names, "Unknown Command")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cmd_id, zbee_nwk_cmd_names, "Unknown Command")); } /* Handle the command. */ diff --git a/epan/dissectors/packet-zbee-zdp.c b/epan/dissectors/packet-zbee-zdp.c index b95ced81b1..40f28408ee 100644 --- a/epan/dissectors/packet-zbee-zdp.c +++ b/epan/dissectors/packet-zbee-zdp.c @@ -1121,7 +1121,7 @@ dissect_zbee_zdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item_append_text(zdp_tree, ", %s", val_to_str(cluster, zbee_zdp_cluster_names, "Unknown Cluster")); } if (check_col(pinfo->cinfo, COL_INFO)) { - col_set_str(pinfo->cinfo, COL_INFO, val_to_str(cluster, zbee_zdp_cluster_names, "Unknown Cluster")); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cluster, zbee_zdp_cluster_names, "Unknown Cluster")); } /* Create a new tvb for the zdp message. */ diff --git a/epan/value_string.c b/epan/value_string.c index e74ea6ceee..d75def715b 100644 --- a/epan/value_string.c +++ b/epan/value_string.c @@ -50,6 +50,22 @@ val_to_str(guint32 val, const value_string *vs, const char *fmt) { } /* Tries to match val against each element in the value_string array vs. + Returns the associated string ptr on a match. + Returns 'unknown_str', on failure. */ +const gchar* +val_to_str_const(guint32 val, const value_string *vs, const char *unknown_str) { + const gchar *ret; + + g_assert(unknown_str != NULL); + + ret = match_strval(val, vs); + if (ret != NULL) + return ret; + + return unknown_str; +} + +/* Tries to match val against each element in the value_string array vs. Returns the associated string ptr, and sets "*idx" to the index in that table, on a match, and returns NULL, and sets "*idx" to -1, on failure. */ diff --git a/epan/value_string.h b/epan/value_string.h index 3fc92c9bf3..a4ae024ef9 100644 --- a/epan/value_string.h +++ b/epan/value_string.h @@ -66,6 +66,11 @@ extern const gchar* match_strval(guint32 val, const value_string *vs); extern const gchar* val_to_str(guint32 val, const value_string *vs, const char *fmt); /* Tries to match val against each element in the value_string array vs. + Returns the associated string ptr on a match. + Returns 'unknown_str', on failure. */ +extern const gchar* val_to_str_const(guint32 val, const value_string *vs, const char *unknown_str); + +/* Tries to match val against each element in the value_string array vs. Returns the associated string ptr, and sets "*idx" to the index in that table, on a match, and returns NULL, and sets "*idx" to -1, on failure. */ |