(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-cops.c) |
| |
| 2514 | | | static proto_item * |
| 2515 | | | info_to_display(tvbuff_t *tvb, proto_item *stt, int offset, int octets, const char *str, const value_string *vsp, int mode,gint *hf_proto_parameter) |
| 2516 | | | { |
| 2517 | | | proto_item *pi = NULL; |
| 2518 | | | guint8 *codestr; |
| 2519 | | | guint8 code8 = 0; |
| 2520 | | | guint16 code16 = 0; |
| 2521 | | | guint32 codeipv4 = 0; |
| 2522 | | | guint32 code32 = 0; |
| 2523 | | | guint64 code64 = 0; |
| 2524 | | | float codefl = 0.0f; |
| 2525 | | | |
| 2526 | | | |
| 2527 | | | if (mode==FMT_STR) { |
| 2528 | | | codestr = tvb_get_string(tvb, offset, octets); |
| 2529 | | | pi = proto_tree_add_string_format(stt, *hf_proto_parameter, tvb, |
| 2530 | | | offset, octets, codestr, "%-28s : %s", str, codestr); |
| 2531 | | | return pi; |
| 2532 | | | } |
| 2533 | | | |
| 2534 | | | |
| 2535 | | | switch (octets) { |
| 2536 | | | |
| 2537 | | | case 1: |
| 2538 | | | |
| 2539 | | | code8 = tvb_get_guint8( tvb, offset ); |
| 2540 | | | if (vsp == NULL) { |
| 2541 | | | |
| 2542 | | | if (mode==FMT_HEX) |
| 2543 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, |
| 2544 | | | offset, octets, code8,"%-28s : 0x%02x",str,code8); |
| 2545 | | | else |
| 2546 | | | |
| 2547 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, |
| 2548 | | | offset, octets, code8,"%-28s : %u",str,code8); |
| 2549 | | | } else { |
| 2550 | | | if (mode==FMT_HEX) |
| 2551 | | | |
| 2552 | | | pi = proto_tree_add_uint_format( |
| 2553 | | | stt, *hf_proto_parameter,tvb, offset, octets, code8, |
| 2554 | | | "%-28s : %s (0x%02x)",str,val_to_str(code8, vsp, "Unknown"),code8); |
| 2555 | | | else |
| 2556 | | | |
| 2557 | | | pi = proto_tree_add_uint_format( |
| 2558 | | | stt, *hf_proto_parameter,tvb, offset, octets, code8, |
| 2559 | | | "%-28s : %s (%u)",str,val_to_str(code8, vsp, "Unknown"),code8); |
| 2560 | | | } |
| 2561 | | | break; |
| 2562 | | | |
| 2563 | | | case 2: |
| 2564 | | | |
| 2565 | | | |
| 2566 | | | code16 = tvb_get_ntohs(tvb,offset); |
| 2567 | | | if (vsp == NULL) { |
| 2568 | | | |
| 2569 | | | if (mode==FMT_HEX) |
| 2570 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, |
| 2571 | | | offset, octets, code16,"%-28s : 0x%04x",str,code16); |
| 2572 | | | else |
| 2573 | | | |
| 2574 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, |
| 2575 | | | offset, octets, code16,"%-28s : %u",str,code16); |
| 2576 | | | } else { |
| 2577 | | | if (mode==FMT_HEX) |
| 2578 | | | |
| 2579 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, |
| 2580 | | | offset, octets, code16,"%-28s : %s (0x%04x)", str, |
| 2581 | | | val_to_str(code16, vsp, "Unknown (0x%04x)"),code16); |
| 2582 | | | else |
| 2583 | | | |
| 2584 | | | pi = proto_tree_add_uint_format( |
| 2585 | | | stt, *hf_proto_parameter,tvb, offset, octets, code16, |
| 2586 | | | "%-28s : %s (%u)",str,val_to_str(code16, vsp, "Unknown (0x%04x)"),code16); |
| 2587 | | | } |
| 2588 | | | break; |
| 2589 | | | |
| 2590 | | | case 4: |
| 2591 | | | |
| 2592 | | | |
| 2593 | | | switch (mode) { |
| 2594 | | | case FMT_FLT: codefl = tvb_get_ntohieee_float(tvb,offset); |
Ignored Return Value
The return value of tvb_get_ntohieee_float() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of tvb_get_ntohieee_float() is checked 97% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt tvb_get_ntohieee_float() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 2595 | | | break; |
| 2596 | | | case FMT_IPv4: codeipv4 = tvb_get_ipv4(tvb, offset); |
| 2597 | | | break; |
| 2598 | | | default: code32 = tvb_get_ntohl(tvb,offset); |
| 2599 | | | } |
| 2600 | | | |
| 2601 | | | if (vsp == NULL) { |
Event 2:
Taking false branch. vsp == (void *)0 evaluates to false.
hide
|
|
| 2602 | | | |
| 2603 | | | if (mode==FMT_HEX) { |
| 2604 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, |
| 2605 | | | offset, octets, code32,"%-28s : 0x%08x",str,code32); |
| 2606 | | | break; |
| 2607 | | | } |
| 2608 | | | |
| 2609 | | | if (mode==FMT_IPv4) { |
| 2610 | | | pi = proto_tree_add_ipv4(stt, *hf_proto_parameter,tvb, offset, octets, codeipv4); |
| 2611 | | | break; |
| 2612 | | | } |
| 2613 | | | |
| 2614 | | | if (mode==FMT_FLT) { |
| 2615 | | | pi = proto_tree_add_float_format(stt, *hf_proto_parameter,tvb, offset, octets, |
| 2616 | | | codefl,"%-28s : %.10g",str,codefl); |
| 2617 | | | break; |
| 2618 | | | } |
| 2619 | | | |
| 2620 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, offset, octets, |
| 2621 | | | code32,"%-28s : %u",str,code32); |
| 2622 | | | } else { |
| 2623 | | | |
| 2624 | | | if (mode==FMT_HEX) |
Event 3:
Taking false branch. mode == 1 evaluates to false.
hide
|
|
| 2625 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, offset, octets, |
| 2626 | | | code32,"%-28s : %s (0x%08x)",str,val_to_str(code32, vsp, "Unknown"),code32); |
| 2627 | | | else |
| 2628 | | | |
| 2629 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter,tvb, offset, octets, |
| 2630 | | | code32,"%-28s : %s (%u)",str,val_to_str(code32, vsp, "Unknown"),code32); |
| 2631 | | | } |
| 2632 | | | break; |
| 2633 | | | |
| 2634 | | | |
| 2635 | | | default: |
| 2636 | | | |
| 2637 | | | if (mode==FMT_HEX) { |
| 2638 | | | pi = proto_tree_add_bytes(stt, *hf_proto_parameter, |
| 2639 | | | tvb, offset, octets, tvb_get_ptr(tvb, offset,octets)); |
| 2640 | | | } else if (mode==FMT_IPv6 && octets==16) { |
| 2641 | | | pi = proto_tree_add_ipv6(stt, *hf_proto_parameter, tvb, offset, octets, |
| 2642 | | | tvb_get_ptr(tvb, offset, octets)); |
| 2643 | | | } else if (mode==FMT_DEC && octets==8) { |
| 2644 | | | code64 = tvb_get_ntoh64(tvb, offset); |
| 2645 | | | pi = proto_tree_add_uint64_format(stt, *hf_proto_parameter, tvb, offset, octets, |
| 2646 | | | code64, "%-28s : %" G_GINT64_MODIFIER "u", str, code64); |
| 2647 | | | } else { |
| 2648 | | | pi = proto_tree_add_uint_format(stt, *hf_proto_parameter, |
| 2649 | | | tvb, offset, octets, code32,"%s",str); |
| 2650 | | | } |
| 2651 | | | break; |
| 2652 | | | |
| 2653 | | | } |
| 2654 | | | return pi; |
| 2655 | | | } |
| |