(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-lldp.c) |
| |
| 721 | | | dissect_lldp_port_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset) |
| 722 | | | { |
| 723 | | | guint8 tempType; |
| 724 | | | guint16 tempShort; |
| 725 | | | guint32 tempLen = 0; |
| 726 | | | const char *strPtr; |
| 727 | | | const guint8 *mac_addr = NULL; |
| 728 | | | guint32 ip_addr; |
| 729 | | | struct e_in6_addr ip6_addr; |
| 730 | | | guint8 addr_family = 0; |
| 731 | | | |
| 732 | | | proto_tree *port_tree = NULL; |
| 733 | | | proto_item *tf = NULL; |
| 734 | | | |
| 735 | | | |
| 736 | | | tempShort = tvb_get_ntohs(tvb, offset); |
| 737 | | | tempType = TLV_TYPE(tempShort); |
| 738 | | | if (tempType != PORT_ID_TLV_TYPE) |
| 739 | | | return -1; |
| 740 | | | |
| 741 | | | |
| 742 | | | tempLen = TLV_INFO_LEN(tempShort); |
| 743 | | | tempType = tvb_get_guint8(tvb, (offset+2)); |
| 744 | | | |
| 745 | | | |
| 746 | | | switch (tempType) |
| 747 | | | { |
| 748 | | | case 3: |
| 749 | | | { |
| 750 | | | if (tempLen != 7) |
| 751 | | | return -1; |
| 752 | | | |
| 753 | | | mac_addr=tvb_get_ptr(tvb, (offset+3), 6); |
| 754 | | | strPtr = ether_to_str(mac_addr); |
| 755 | | | |
| 756 | | | break; |
| 757 | | | } |
| 758 | | | case 4: |
| 759 | | | { |
| 760 | | | |
| 761 | | | addr_family = tvb_get_guint8(tvb,offset+3); |
| 762 | | | |
| 763 | | | switch(addr_family){ |
| 764 | | | case AFNUM_INET: |
| 765 | | | if (tempLen == 6){ |
| 766 | | | ip_addr = tvb_get_ipv4(tvb, (offset+4)); |
| 767 | | | strPtr = ip_to_str((guint8 *)&ip_addr); |
Ignored Return Value
The return value of ip_to_str() 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 ip_to_str() is checked 99% 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 ip_to_str() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 768 | | | }else{ |
| 769 | | | return -1; |
| 770 | | | } |
| 771 | | | break; |
| 772 | | | case AFNUM_INET6: |
| 773 | | | if (tempLen == 18){ |
| 774 | | | tvb_get_ipv6(tvb, (offset+4), &ip6_addr); |
| 775 | | | strPtr = ip6_to_str(&ip6_addr); |
| 776 | | | }else{ |
| 777 | | | return -1; |
| 778 | | | } |
| 779 | | | break; |
| 780 | | | default: |
| 781 | | | strPtr = tvb_bytes_to_str(tvb, (offset+4), (tempLen-2)); |
| 782 | | | break; |
| 783 | | | } |
| 784 | | | break; |
| 785 | | | } |
| 786 | | | default: |
| 787 | | | { |
| 788 | | | strPtr = tvb_format_stringzpad(tvb, (offset+3), (tempLen-1)); |
| 789 | | | |
| 790 | | | break; |
| 791 | | | } |
| 792 | | | } |
| 793 | | | |
| 794 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
Event 2:
Skipping " if". check_col(...) evaluates to false.
hide
|
|
| 795 | | | col_append_fstr(pinfo->cinfo, COL_INFO, "Port Id = %s ", strPtr); |
| 796 | | | |
| 797 | | | if (tree) |
Event 3:
Taking true branch. tree evaluates to true.
hide
|
|
| 798 | | | { |
| 799 | | | |
| 800 | | | tf = proto_tree_add_text(tree, tvb, offset, (tempLen + 2), "Port Subtype = %s", |
| 801 | | | val_to_str(tempType, port_id_subtypes, "Unknown" )); |
| 802 | | | port_tree = proto_item_add_subtree(tf, ett_port_id); |
| 803 | | | |
| 804 | | | proto_tree_add_item(port_tree, hf_lldp_tlv_type, tvb, offset, 2, FALSE); |
| 805 | | | proto_tree_add_item(port_tree, hf_lldp_tlv_len, tvb, offset, 2, FALSE); |
| 806 | | | |
| 807 | | | |
| 808 | | | proto_tree_add_item(port_tree, hf_port_id_subtype, tvb, (offset+2), 1, FALSE); |
| 809 | | | |
| 810 | | | |
| 811 | | | |
| 812 | | | switch (tempType) |
Event 4:
tempType evaluates to 4.
hide
|
|
| 813 | | | { |
| 814 | | | case 3: |
| 815 | | | proto_tree_add_ether(port_tree, hf_port_id_mac, tvb, (offset+3), 6, mac_addr); |
| 816 | | | break; |
| 817 | | | case 4: |
| 818 | | | |
| 819 | | | |
| 820 | | | |
| 821 | | | |
| 822 | | | |
| 823 | | | proto_tree_add_item(port_tree, hf_lldp_network_address_family, tvb, offset+3, 1, FALSE); |
| 824 | | | switch(addr_family){ |
Event 5:
addr_family evaluates to 1.
hide
|
|
| 825 | | | case AFNUM_INET: |
| 826 | | | proto_tree_add_ipv4(port_tree, hf_port_id_ip4, tvb, (offset+4), 4, ip_addr); |
| 827 | | | break; |
| 828 | | | case AFNUM_INET6: |
| 829 | | | proto_tree_add_ipv6(port_tree, hf_port_id_ip6, tvb, (offset+4), 16, ip6_addr.bytes); |
| 830 | | | break; |
| 831 | | | default: |
| 832 | | | proto_tree_add_text(port_tree, tvb, (offset+4), (tempLen-2), "Port Id: %s", strPtr); |
| 833 | | | break; |
| 834 | | | } |
| 835 | | | break; |
| 836 | | | default: |
| 837 | | | proto_tree_add_text(port_tree, tvb, (offset+3), (tempLen-1), "Port Id: %s", strPtr); |
| 838 | | | proto_item_append_text(tf, ", Id: %s", strPtr); |
| 839 | | | break; |
| 840 | | | } |
| 841 | | | |
| 842 | | | } |
| 843 | | | |
| 844 | | | return (tempLen + 2); |
| 845 | | | } |
| |