diff --git a/epan/dissectors/packet-zrtp.c b/epan/dissectors/packet-zrtp.c index 04938bc6a0..3b84372f1d 100644 --- a/epan/dissectors/packet-zrtp.c +++ b/epan/dissectors/packet-zrtp.c @@ -1,6 +1,7 @@ /* packet-zrtp.c * Routines for zrtp packet dissection * IETF draft draft-zimmermann-avt-zrtp-22 + * RFC 6189 * Copyright 2007, Sagar Pai * * Wireshark - Network traffic analyzer @@ -553,7 +554,7 @@ static void dissect_Commit(tvbuff_t *tvb, packet_info *pinfo, proto_tree *zrtp_tree) { unsigned int msg_offset = 12; unsigned int data_offset = 56; - unsigned char value[5]; + gchar *value; int key_type = 0; /* 0 - other type @@ -567,20 +568,16 @@ dissect_Commit(tvbuff_t *tvb, packet_info *pinfo, proto_tree *zrtp_tree) { proto_tree_add_item(zrtp_tree, hf_zrtp_msg_hash_image, tvb, msg_offset+12, 32, ENC_NA); /* ZID */ proto_tree_add_item(zrtp_tree, hf_zrtp_msg_zid, tvb, data_offset+0, 12, ENC_NA); - tvb_memcpy(tvb, (void *)value, data_offset+12, 4); - value[4] = '\0'; + value = (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, data_offset+12, 4, ENC_ASCII|ENC_NA); proto_tree_add_string_format_value(zrtp_tree, hf_zrtp_msg_hash, tvb, data_offset+12, 4, value, "%s", key_to_val(value, 4, zrtp_hash_type_vals, "Unknown hash type %s")); - tvb_memcpy(tvb, (void *)value, data_offset+16, 4); - value[4] = '\0'; + value = (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, data_offset+16, 4, ENC_ASCII|ENC_NA); proto_tree_add_string_format_value(zrtp_tree, hf_zrtp_msg_cipher, tvb, data_offset+16, 4, value, "%s", key_to_val(value, 4, zrtp_cipher_type_vals, "Unknown cipher type %s")); - tvb_memcpy(tvb, (void *)value, data_offset+20, 4); - value[4] = '\0'; + value = (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, data_offset+20, 4, ENC_ASCII|ENC_NA); proto_tree_add_string_format(zrtp_tree, hf_zrtp_msg_at, tvb, data_offset+20, 4, value, "Auth tag: %s", key_to_val(value, 4, zrtp_auth_tag_vals, "Unknown auth tag %s")); - tvb_memcpy(tvb, (void *)value, data_offset+24, 4); - value[4] = '\0'; + value = (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, data_offset+24, 4, ENC_ASCII|ENC_NA); proto_tree_add_string_format_value(zrtp_tree, hf_zrtp_msg_keya, tvb, data_offset+24, 4, value, "%s", key_to_val(value, 4, zrtp_key_agreement_vals, "Unknown key agreement %s")); @@ -589,8 +586,7 @@ dissect_Commit(tvbuff_t *tvb, packet_info *pinfo, proto_tree *zrtp_tree) { } else if (!strncmp(value, "Prsh", 4)) { key_type = 2; } - tvb_memcpy(tvb, (void *)value, data_offset+28, 4); - value[4] = '\0'; + value = (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, data_offset+28, 4, ENC_ASCII|ENC_NA); proto_tree_add_string_format(zrtp_tree, hf_zrtp_msg_sas, tvb, data_offset+28, 4, value, "SAS type: %s", key_to_val(value, 4, zrtp_sas_type_vals, "Unknown SAS type %s")); @@ -629,14 +625,13 @@ dissect_Hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *zrtp_tree) { unsigned int run_offset; unsigned int hc, cc, ac, kc, sc; unsigned int vhc, vcc, vac, vkc, vsc; - unsigned char value[5]; - unsigned char version_str[5]; + gchar *value; + gchar *version_str; proto_tree *tmp_tree; col_set_str(pinfo->cinfo, COL_INFO, "Hello Packet"); - tvb_memcpy(tvb, version_str, msg_offset+12, 4); - version_str[4] = '\0'; + version_str = (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, msg_offset+12, 4, ENC_ASCII|ENC_NA); if (check_valid_version(version_str) == NULL) { col_set_str(pinfo->cinfo, COL_INFO, "Unsupported version of ZRTP protocol"); } @@ -668,8 +663,7 @@ dissect_Hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *zrtp_tree) { tmp_tree = proto_item_add_subtree(ti, ett_zrtp_msg_hc); run_offset = data_offset+4; for (i=0; i