(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/flow_graph.c) |
| |
| 310 | | | static int flow_graph_tcp_add_to_graph(packet_info *pinfo, const struct *tcph) |
| 311 | | | { |
| 312 | | | graph_analysis_item_t *gai; |
| 313 | | | |
| 314 | | | const gchar *fstr[] = {"FIN", "SYN", "RST", "PSH", "ACK", "URG", "ECN", "CWR" }; |
| 315 | | | guint i, bpos; |
| 316 | | | gboolean flags_found = FALSE; |
| 317 | | | gchar flags[64]; |
| 318 | | | |
| 319 | | | gai = g_malloc(sizeof(graph_analysis_item_t)); |
| 320 | | | gai->frame_num = pinfo->fd->num; |
| 321 | | | gai->time= nstime_to_sec(&pinfo->fd->rel_ts); |
| 322 | | | if (node_addr_type == NET_SRCDST) { |
| 323 | | | COPY_ADDRESS(&(gai->src_addr),&(pinfo->net_src));
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
107 | #define COPY_ADDRESS(to, from) { \ |
108 | guint8 *COPY_ADDRESS_data; \ |
109 | (to)->type = (from)->type; \ |
110 | (to)->len = (from)->len; \ |
111 | COPY_ADDRESS_data = g_malloc((from)->len); \ |
112 | memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \ |
113 | (to)->data = COPY_ADDRESS_data; \ |
114 | } |
| |
|
| 324 | | | COPY_ADDRESS(&(gai->dst_addr),&(pinfo->net_dst));
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
107 | #define COPY_ADDRESS(to, from) { \ |
108 | guint8 *COPY_ADDRESS_data; \ |
109 | (to)->type = (from)->type; \ |
110 | (to)->len = (from)->len; \ |
111 | COPY_ADDRESS_data = g_malloc((from)->len); \ |
112 | memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \ |
113 | (to)->data = COPY_ADDRESS_data; \ |
114 | } |
| |
|
| 325 | | | } else { |
| 326 | | | COPY_ADDRESS(&(gai->src_addr),&(pinfo->src));
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
107 | #define COPY_ADDRESS(to, from) { \ |
108 | guint8 *COPY_ADDRESS_data; \ |
109 | (to)->type = (from)->type; \ |
110 | (to)->len = (from)->len; \ |
111 | COPY_ADDRESS_data = g_malloc((from)->len); \ |
112 | memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \ |
113 | (to)->data = COPY_ADDRESS_data; \ |
114 | } |
| |
|
| 327 | | | COPY_ADDRESS(&(gai->dst_addr),&(pinfo->dst));
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
107 | #define COPY_ADDRESS(to, from) { \ |
108 | guint8 *COPY_ADDRESS_data; \ |
109 | (to)->type = (from)->type; \ |
110 | (to)->len = (from)->len; \ |
111 | COPY_ADDRESS_data = g_malloc((from)->len); \ |
112 | memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \ |
113 | (to)->data = COPY_ADDRESS_data; \ |
114 | } |
| |
|
| 328 | | | } |
| 329 | | | gai->port_src=pinfo->srcport; |
| 330 | | | gai->port_dst=pinfo->destport; |
| 331 | | | |
| 332 | | | flags[0] = '\0'; |
| 333 | | | for (i = 0; i < 8; i++) { |
| 334 | | | bpos = 1 << i; |
| 335 | | | if (tcph->th_flags & bpos) { |
| 336 | | | if (flags_found) { |
| 337 | | | g_strlcat(flags, ", ", sizeof(flags)); |
| 338 | | | } |
| 339 | | | g_strlcat(flags, fstr[i], sizeof(flags)); |
| 340 | | | flags_found = TRUE; |
| 341 | | | } |
| 342 | | | } |
| 343 | | | if (flags[0] == '\0') { |
Redundant Condition
flags[0] == 0 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 flags[0] == 0 cannot be false.
- A crashing bug occurs on every path where flags[0] == 0 could have evaluated to false. Look for a preceding Null Pointer Dereference or Division By Zero warning.
|
|
| 344 | | | g_snprintf (flags, sizeof(flags), "<None>"); |
| 345 | | | } |
| 346 | | | |
| 347 | | | if ((tcph->th_have_seglen)&&(tcph->th_seglen!=0)){ |
| 348 | | | gai->frame_label = g_strdup_printf("%s - Len: %u",flags, tcph->th_seglen); |
| 349 | | | } |
| 350 | | | else{ |
| 351 | | | gai->frame_label = g_strdup(flags); |
| 352 | | | } |
| 353 | | | |
| 354 | | | gai-> = g_strdup_printf("Seq = %u Ack = %u",tcph->th_seq, tcph->th_ack); |
| 355 | | | |
| 356 | | | gai->line_style=1; |
| 357 | | | gai->conv_num=0; |
| 358 | | | gai->display=TRUE; |
| 359 | | | |
| 360 | | | graph_analysis->list = g_list_append(graph_analysis->list, gai); |
| 361 | | | |
| 362 | | | return 1; |
| 363 | | | |
| 364 | | | } |
| |