(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/main_menu.c) |
| |
| 195 | | | static char * |
| 196 | | | build_conversation_filter(int action, gboolean show_dialog) |
| 197 | | | { |
| 198 | | | packet_info *pi = &cfile.edt->pi; |
| 199 | | | char *buf; |
| 200 | | | |
| 201 | | | |
| 202 | | | switch(action) { |
| 203 | | | case(CONV_CBA): |
| 204 | | | if (pi->profinet_type == 0) { |
| 205 | | | if (show_dialog) { |
| 206 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, |
| 207 | | | "Error filtering conversation. Please make\n" |
| 208 | | | "sure you have a PROFINET CBA packet selected."); |
| 209 | | | } |
| 210 | | | return NULL; |
| 211 | | | } |
| 212 | | | |
| 213 | | | if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 |
| 214 | | | && pi->ipproto == IP_PROTO_TCP ) { |
| 215 | | | |
| 216 | | | switch(pi->profinet_type) { |
| 217 | | | case(1): |
| 218 | | | buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 0)", |
| 219 | | | ip_to_str( pi->net_dst.data), |
| 220 | | | ip_to_str( pi->net_src.data), |
| 221 | | | ip_to_str( pi->net_src.data), |
| 222 | | | ip_to_str( pi->net_dst.data)); |
| 223 | | | break; |
| 224 | | | case(2): |
| 225 | | | buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 0)", |
| 226 | | | ip_to_str( pi->net_src.data), |
| 227 | | | ip_to_str( pi->net_dst.data), |
| 228 | | | ip_to_str( pi->net_dst.data), |
| 229 | | | ip_to_str( pi->net_src.data)); |
| 230 | | | break; |
| 231 | | | case(3): |
| 232 | | | buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.srt == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.srt == 0)", |
| 233 | | | ip_to_str( pi->net_dst.data), |
| 234 | | | ip_to_str( pi->net_src.data), |
| 235 | | | ip_to_str( pi->net_src.data), |
| 236 | | | ip_to_str( pi->net_dst.data)); |
| 237 | | | break; |
| 238 | | | case(4): |
| 239 | | | buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.srt == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.srt == 0)", |
| 240 | | | ip_to_str( pi->net_src.data), |
| 241 | | | ip_to_str( pi->net_dst.data), |
| 242 | | | ip_to_str( pi->net_dst.data), |
| 243 | | | ip_to_str( pi->net_src.data)); |
| 244 | | | break; |
| 245 | | | default: |
| 246 | | | return NULL; |
| 247 | | | } |
| 248 | | | } else { |
| 249 | | | return NULL; |
| 250 | | | } |
| 251 | | | break; |
| 252 | | | case(CONV_TCP): |
| 253 | | | if (pi->ipproto != IP_PROTO_TCP) { |
| 254 | | | if (show_dialog) { |
| 255 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, |
| 256 | | | "Error filtering conversation. Please make\n" |
| 257 | | | "sure you have a TCP packet selected."); |
| 258 | | | } |
| 259 | | | return NULL; |
| 260 | | | } |
| 261 | | | |
| 262 | | | if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) { |
| 263 | | | |
| 264 | | | buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)", |
| 265 | | | ip_to_str( pi->net_src.data), |
| 266 | | | ip_to_str( pi->net_dst.data), |
| 267 | | | pi->srcport, pi->destport ); |
| 268 | | | } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) { |
| 269 | | | |
| 270 | | | buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)", |
| 271 | | | ip6_to_str((const struct e_in6_addr *)pi->net_src.data), |
| 272 | | | ip6_to_str((const struct e_in6_addr *)pi->net_dst.data), |
| 273 | | | pi->srcport, pi->destport ); |
| 274 | | | } else { |
| 275 | | | return NULL; |
| 276 | | | } |
| 277 | | | break; |
| 278 | | | case(CONV_UDP): |
| 279 | | | if (pi->ipproto != IP_PROTO_UDP) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/ipproto.h |
| |
52 | #define IP_PROTO_UDP 17 /* user datagram protocol - RFC768 */ |
| |
|
| 280 | | | if (show_dialog) { |
| 281 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, |
| 282 | | | "Error filtering conversation. Please make\n" |
| 283 | | | "sure you have a UDP packet selected."); |
| 284 | | | } |
| 285 | | | return NULL; |
| 286 | | | } |
| 287 | | | |
| 288 | | | if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) { |
| 289 | | | |
| 290 | | | buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (udp.port eq %d and udp.port eq %d)", |
| 291 | | | ip_to_str( pi->net_src.data), |
| 292 | | | ip_to_str( pi->net_dst.data), |
| 293 | | | pi->srcport, pi->destport ); |
| 294 | | | } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) { |
| 295 | | | |
| 296 | | | buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (udp.port eq %d and udp.port eq %d)", |
| 297 | | | ip6_to_str((const struct e_in6_addr *)pi->net_src.data), |
| 298 | | | ip6_to_str((const struct e_in6_addr *)pi->net_dst.data), |
| 299 | | | pi->srcport, pi->destport ); |
| 300 | | | } else { |
| 301 | | | return NULL; |
| 302 | | | } |
| 303 | | | break; |
| 304 | | | case(CONV_IP): |
| 305 | | | if ((pi->ethertype != ETHERTYPE_IP) && (pi->ethertype != ETHERTYPE_IPv6)) { |
| 306 | | | if (show_dialog) { |
| 307 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, |
| 308 | | | "Error filtering conversation. Please make\n" |
| 309 | | | "sure you have a IP packet selected."); |
| 310 | | | } |
| 311 | | | return NULL; |
| 312 | | | } |
| 313 | | | |
| 314 | | | if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) { |
| 315 | | | |
| 316 | | | buf = g_strdup_printf("ip.addr eq %s and ip.addr eq %s", |
| 317 | | | ip_to_str( pi->net_src.data), |
| 318 | | | ip_to_str( pi->net_dst.data)); |
| 319 | | | } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) { |
| 320 | | | |
| 321 | | | buf = g_strdup_printf("ipv6.addr eq %s and ipv6.addr eq %s", |
| 322 | | | ip6_to_str((const struct e_in6_addr *)pi->net_src.data), |
| 323 | | | ip6_to_str((const struct e_in6_addr *)pi->net_dst.data)); |
| 324 | | | } else { |
| 325 | | | return NULL; |
| 326 | | | } |
| 327 | | | break; |
| 328 | | | case(CONV_ETHER): |
| 329 | | | |
| 330 | | | |
| 331 | | | |
| 332 | | | if (pi->dl_src.type != AT_ETHER) { |
| 333 | | | if (show_dialog) { |
| 334 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, |
| 335 | | | "Error filtering conversation. Please make\n" |
| 336 | | | "sure you have a Ethernet packet selected."); |
| 337 | | | } |
| 338 | | | return NULL; |
| 339 | | | } |
| 340 | | | |
| 341 | | | if( pi->dl_src.type == AT_ETHER && pi->dl_dst.type == AT_ETHER ) { |
Redundant Condition
pi->dl_src.type == AT_ETHER always evaluates to true. This may be because: - There is a constant assignment to one or more of the variables involved.
- An earlier conditional statement has already ensured that pi->dl_src.type == AT_ETHER cannot be false.
- A crashing bug occurs on every path where pi->dl_src.type == AT_ETHER could have evaluated to false. Look for a preceding Null Pointer Dereference or Division By Zero warning.
|
|
| 342 | | | |
| 343 | | | buf = g_strdup_printf("eth.addr eq %s and eth.addr eq %s", |
| 344 | | | ether_to_str( pi->dl_src.data), |
| 345 | | | ether_to_str( pi->dl_dst.data)); |
| 346 | | | } else { |
| 347 | | | return NULL; |
| 348 | | | } |
| 349 | | | break; |
| 350 | | | default: |
| 351 | | | return NULL; |
| 352 | | | } |
| 353 | | | |
| 354 | | | return buf; |
| 355 | | | } |
| |