(/home/sate/Testcases/c/cve/wireshark-1.2.0/tap-iousers.c) |
| |
| 74 | | | iousers_udpip_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vudph) |
| 75 | | | { |
| 76 | | | io_users_t *iu=arg; |
| 77 | | | const e_udphdr *udph=vudph; |
| 78 | | | char name1[256],name2[256]; |
| 79 | | | io_users_item_t *iui; |
| 80 | | | int direction=0; |
| 81 | | | |
| 82 | | | if(udph->uh_sport>udph->uh_dport){ |
| 83 | | | direction=0; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 84 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport)); |
| 85 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport)); |
| 86 | | | } else if(udph->uh_sport<udph->uh_dport){ |
| 87 | | | direction=1; |
| 88 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport)); |
| 89 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport)); |
| 90 | | | } else if(CMP_ADDRESS(&udph->ip_src, &udph->ip_dst)>0){
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
78 | #define CMP_ADDRESS(addr1, addr2) \ |
79 | ( ((addr1)->type > (addr2)->type)?1: \ |
80 | ((addr1)->type < (addr2)->type)?-1: \ |
81 | ((addr1)->len > (addr2)->len) ?1: \ |
82 | ((addr1)->len < (addr2)->len) ?-1: \ |
83 | memcmp((addr1)->data, (addr2)->data, (addr1)->len)\ |
84 | ) |
| |
|
| 91 | | | direction=0; |
| 92 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport)); |
| 93 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport)); |
| 94 | | | } else { |
| 95 | | | direction=1; |
| 96 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport)); |
| 97 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport)); |
| 98 | | | } |
| 99 | | | |
| 100 | | | for(iui=iu->items;iui;iui=iui->next){ |
| 101 | | | if((!strcmp(iui->name1, name1)) |
| 102 | | | && (!strcmp(iui->name2, name2)) ){ |
| 103 | | | break; |
| 104 | | | } |
| 105 | | | } |
| 106 | | | |
| 107 | | | if(!iui){ |
| 108 | | | iui=g_malloc(sizeof(io_users_item_t)); |
| 109 | | | iui->next=iu->items; |
| 110 | | | iu->items=iui; |
| 111 | | | |
| 112 | | | iui->name1=g_strdup(name1); |
| 113 | | | |
| 114 | | | iui->name2=g_strdup(name2); |
| 115 | | | iui->frames1=0; |
| 116 | | | iui->frames2=0; |
| 117 | | | iui->bytes1=0; |
| 118 | | | iui->bytes2=0; |
| 119 | | | } |
| 120 | | | |
| 121 | | | if(direction){ |
| 122 | | | iui->frames1++; |
| 123 | | | iui->bytes1+=pinfo->fd->pkt_len; |
| 124 | | | } else { |
| 125 | | | iui->frames2++; |
| 126 | | | iui->bytes2+=pinfo->fd->pkt_len; |
| 127 | | | } |
| 128 | | | |
| 129 | | | return 1; |
| 130 | | | } |
| |