diff options
author | etxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-10-27 15:35:48 +0000 |
---|---|---|
committer | etxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-10-27 15:35:48 +0000 |
commit | 8a970b6736d79d05516285cf453afbd1771ecf13 (patch) | |
tree | 3cb75bf4e52518862a9752ca4bbb98352c5858a4 | |
parent | 1dae9cf9c66e089fe8f0629524a0260fabdce0ef (diff) |
The comparison with the UAT keys are broken, this is
a fix for fetching the IP address.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39633 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | epan/dissectors/packet-ipsec.c | 98 |
1 files changed, 8 insertions, 90 deletions
diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 759158ad7d..59b0138884 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -1003,7 +1003,6 @@ dissect_esp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint i = 0; #ifdef HAVE_LIBGCRYPT - char res[3]; /* Packet Variables related */ gchar *ip_src = NULL; @@ -1107,94 +1106,15 @@ dissect_esp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if(g_esp_enable_encryption_decode || g_esp_enable_authentication_check) { /* Get Source & Destination Addresses in gchar * with all the bytes available. */ - switch (pinfo -> src.type) - { - - case AT_IPv4 : - { - const guint8 *srcaddr = pinfo -> src.data; - const guint8 *dstaddr = pinfo -> dst.data; - - ip_src = (gchar *) g_malloc((IPSEC_STRLEN_IPV4 + 1) * sizeof(gchar)); - ip_dst = (gchar *) g_malloc((IPSEC_STRLEN_IPV4 + 1) * sizeof(gchar)); - protocol_typ = IPSEC_SA_IPV4; - - for(i = 0 ; i < pinfo -> src.len; i++) - { - if(srcaddr[i] < 16) - { - g_snprintf(res,3,"0%X ", srcaddr[i]); - } - else - { - g_snprintf(res,3,"%X ", srcaddr[i]); - } - memcpy(ip_src + i*2, res, 2); - } - ip_src[IPSEC_STRLEN_IPV4] = '\0'; - - for(i = 0 ; i < pinfo -> dst.len; i++) - { - if(dstaddr[i] < 16) - { - g_snprintf(res,3,"0%X ", dstaddr[i]); - } - else - { - g_snprintf(res,3,"%X ", dstaddr[i]); - } - memcpy(ip_dst + i*2, res, 2); - } - ip_dst[IPSEC_STRLEN_IPV4] = '\0'; - - get_address_ok = TRUE; - break; - } - case AT_IPv6 : - { - const guint8 *srcaddr = pinfo -> src.data; - const guint8 *dstaddr = pinfo -> dst.data; - - ip_src = (gchar *) g_malloc((IPSEC_STRLEN_IPV6 + 1) * sizeof(gchar)); - ip_dst = (gchar *) g_malloc((IPSEC_STRLEN_IPV6 + 1) * sizeof(gchar)); - protocol_typ = IPSEC_SA_IPV6; - - for(i = 0 ; i < pinfo -> src.len; i++) - { - if(srcaddr[i] < 16) - { - g_snprintf(res,3,"0%X ", srcaddr[i]); - } - else - { - g_snprintf(res,3,"%X ", srcaddr[i]); - } - memcpy(ip_src + i*2, res, 2); - } - ip_src[IPSEC_STRLEN_IPV6] = '\0'; - - for(i = 0 ; i < pinfo -> dst.len; i++) - { - if(dstaddr[i] < 16) - { - g_snprintf(res,3,"0%X ", dstaddr[i]); - } - else - { - g_snprintf(res,3,"%X ", dstaddr[i]); - } - memcpy(ip_dst + i*2, res, 2); - } - ip_dst[IPSEC_STRLEN_IPV6] = '\0'; - - get_address_ok = TRUE; - break; - default: - /* Probably some error display should go in here??? */ - ; - } - } + if (pinfo->src.type == AT_IPv4){ + protocol_typ = IPSEC_SA_IPV4; + }else if (pinfo->src.type == AT_IPv6){ + protocol_typ = IPSEC_SA_IPV6; + } + ip_src = ep_address_to_str(&pinfo->src); + ip_dst = ep_address_to_str(&pinfo->src); + get_address_ok = TRUE; /* The packet cannot be decoded using the SAD */ if(g_esp_enable_null_encryption_decode_heuristic && !get_address_ok) @@ -1910,8 +1830,6 @@ dissect_esp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) null_encryption_decode_heuristic = g_esp_enable_null_encryption_decode_heuristic; } - g_free(ip_src); - g_free(ip_dst); if(esp_auth_key_len != 0) g_free(esp_auth_key); if(esp_crypt_key_len != 0) |