(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-pgm.c) |
| |
| 799 | | | dissect_pgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
| 800 | | | { |
| 801 | | | guint16 pgmhdr_sport; |
| 802 | | | guint16 pgmhdr_dport; |
| 803 | | | guint8 pgmhdr_type; |
| 804 | | | guint8 pgmhdr_opts; |
| 805 | | | guint16 pgmhdr_cksum; |
| 806 | | | guint16 pgmhdr_tsdulen; |
| 807 | | | guint32 sqn; |
| 808 | | | guint16 afi; |
| 809 | | | |
| 810 | | | guint plen = 0; |
| 811 | | | proto_item *ti; |
| 812 | | | const char *pktname; |
| 813 | | | const char *pollstname; |
| 814 | | | char *gsi; |
| 815 | | | gboolean isdata = FALSE; |
| 816 | | | guint pgmlen, reportedlen; |
| 817 | | | |
| 818 | | | if (check_col(pinfo->cinfo, COL_PROTOCOL)) |
| 819 | | | col_set_str(pinfo->cinfo, COL_PROTOCOL, "PGM"); |
| 820 | | | |
| 821 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 822 | | | col_clear(pinfo->cinfo, COL_INFO); |
| 823 | | | if (tvb_reported_length_remaining(tvb, 0) < 18) { |
| 824 | | | col_set_str(pinfo->cinfo, COL_INFO, |
| 825 | | | "Packet too small"); |
| 826 | | | return; |
| 827 | | | } |
| 828 | | | } |
| 829 | | | |
| 830 | | | pinfo->srcport = pgmhdr_sport = tvb_get_ntohs(tvb, 0); |
| 831 | | | pinfo->destport = pgmhdr_dport = tvb_get_ntohs(tvb, 2); |
| 832 | | | |
| 833 | | | pgmhdr_type = tvb_get_guint8(tvb, 4); |
| 834 | | | pktname = val_to_str(pgmhdr_type, type_vals, "Unknown (0x%02x)"); |
| 835 | | | |
| 836 | | | pgmhdr_opts = tvb_get_guint8(tvb, 5); |
| 837 | | | pgmhdr_cksum = tvb_get_ntohs(tvb, 6); |
| 838 | | | gsi = tvb_bytes_to_str(tvb, 8, 6); |
Ignored Return Value
The return value of tvb_bytes_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 tvb_bytes_to_str() is checked 98% 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_bytes_to_str() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 839 | | | pgmhdr_tsdulen = tvb_get_ntohs(tvb, 14); |
| 840 | | | sqn = tvb_get_ntohl(tvb, 16); |
| 841 | | | |
| 842 | | | switch(pgmhdr_type) { |
Event 2:
Executing default case.
hide
|
|
| 843 | | | case PGM_SPM_PCKT: |
| 844 | | | case PGM_NAK_PCKT: |
| 845 | | | case PGM_NNAK_PCKT: |
| 846 | | | case PGM_NCF_PCKT: |
| 847 | | | case PGM_POLR_PCKT: |
| 848 | | | case PGM_ACK_PCKT: |
| 849 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 850 | | | col_add_fstr(pinfo->cinfo, COL_INFO, |
| 851 | | | "%-5s sqn 0x%x gsi %s", pktname, sqn, gsi); |
| 852 | | | } |
| 853 | | | break; |
| 854 | | | case PGM_RDATA_PCKT: |
| 855 | | | case PGM_ODATA_PCKT: |
| 856 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 857 | | | col_add_fstr(pinfo->cinfo, COL_INFO, |
| 858 | | | "%-5s sqn 0x%x gsi %s tsdulen %d", pktname, sqn, gsi, |
| 859 | | | pgmhdr_tsdulen); |
| 860 | | | } |
| 861 | | | isdata = TRUE; |
| 862 | | | break; |
| 863 | | | case PGM_POLL_PCKT: { |
| 864 | | | guint16 poll_stype = tvb_get_ntohs(tvb, 22); |
| 865 | | | pollstname = val_to_str(poll_stype, poll_subtype_vals, "Unknown (0x%02x)"); |
| 866 | | | |
| 867 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 868 | | | col_add_fstr(pinfo->cinfo, COL_INFO, |
| 869 | | | "%-5s sqn 0x%x gsi %s subtype %s", |
| 870 | | | pktname, sqn, gsi, pollstname); |
| 871 | | | } |
| 872 | | | } |
| 873 | | | break; |
| 874 | | | default: |
| 875 | | | return; |
| 876 | | | } |
| 877 | | | |
| 878 | | | { |
| 879 | | | proto_tree *pgm_tree = NULL; |
| 880 | | | proto_tree *opt_tree = NULL; |
| 881 | | | proto_tree *type_tree = NULL; |
| 882 | | | proto_item *tf, *hidden_item; |
| 883 | | | ptvcursor_t* cursor; |
| 884 | | | |
| 885 | | | ti = proto_tree_add_protocol_format(tree, proto_pgm, |
| 886 | | | tvb, 0, -1, |
| 887 | | | "Pragmatic General Multicast: Type %s" |
| 888 | | | " Src Port %u, Dst Port %u, GSI %s", pktname, |
| 889 | | | pgmhdr_sport, pgmhdr_dport, gsi); |
| 890 | | | |
| 891 | | | pgm_tree = proto_item_add_subtree(ti, ett_pgm); |
| 892 | | | |
| 893 | | | cursor = ptvcursor_new(pgm_tree, tvb, 0); |
| 894 | | | |
| 895 | | | hidden_item = proto_tree_add_item(pgm_tree, hf_pgm_port, tvb, 0, 2, FALSE); |
| 896 | | | PROTO_ITEM_SET_HIDDEN(hidden_item);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
319 | #define PROTO_ITEM_SET_HIDDEN(proto_item) \ |
320 | ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
246 | #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag) |
| |
|
| 897 | | | hidden_item = proto_tree_add_item(pgm_tree, hf_pgm_port, tvb, 2, 2, FALSE); |
| 898 | | | PROTO_ITEM_SET_HIDDEN(hidden_item);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
319 | #define PROTO_ITEM_SET_HIDDEN(proto_item) \ |
320 | ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
246 | #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag) |
| |
|
| 899 | | | ptvcursor_add(cursor, hf_pgm_main_sport, 2, FALSE); |
| 900 | | | ptvcursor_add(cursor, hf_pgm_main_dport, 2, FALSE); |
| 901 | | | ptvcursor_add(cursor, hf_pgm_main_type, 1, FALSE); |
| 902 | | | |
| 903 | | | tf = proto_tree_add_uint_format(pgm_tree, hf_pgm_main_opts, tvb, |
| 904 | | | ptvcursor_current_offset(cursor), 1, pgmhdr_opts, "Options: %s (0x%x)", |
| 905 | | | optsstr(pgmhdr_opts), pgmhdr_opts); |
| 906 | | | opt_tree = proto_item_add_subtree(tf, ett_pgm_optbits); |
| 907 | | | ptvcursor_set_tree(cursor, opt_tree); |
| 908 | | | |
| 909 | | | ptvcursor_add_no_advance(cursor, hf_pgm_main_opts_opt, 1, FALSE); |
| 910 | | | ptvcursor_add_no_advance(cursor, hf_pgm_main_opts_netsig, 1, FALSE); |
| 911 | | | ptvcursor_add_no_advance(cursor, hf_pgm_main_opts_varlen, 1, FALSE); |
| 912 | | | ptvcursor_add(cursor, hf_pgm_main_opts_parity, 1, FALSE); |
| 913 | | | ptvcursor_set_tree(cursor, pgm_tree); |
| 914 | | | |
| 915 | | | |
| 916 | | | if ((pgmhdr_type != PGM_RDATA_PCKT) && (pgmhdr_type != PGM_ODATA_PCKT) && |
| 917 | | | (pgmhdr_cksum == 0)) |
| 918 | | | { |
| 919 | | | proto_tree_add_uint_format(pgm_tree, hf_pgm_main_cksum, tvb, |
| 920 | | | ptvcursor_current_offset(cursor), 2, pgmhdr_cksum, "Checksum: not available"); |
| 921 | | | } else { |
| 922 | | | reportedlen = tvb_reported_length(tvb); |
| 923 | | | pgmlen = tvb_length(tvb); |
| 924 | | | if (pgm_check_checksum && pgmlen >= reportedlen) { |
| 925 | | | vec_t cksum_vec[1]; |
| 926 | | | guint16 computed_cksum; |
| 927 | | | |
| 928 | | | cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, pgmlen); |
| 929 | | | cksum_vec[0].len = pgmlen; |
| 930 | | | computed_cksum = in_cksum(&cksum_vec[0], 1); |
| 931 | | | if (computed_cksum == 0) { |
| 932 | | | proto_tree_add_uint_format(pgm_tree, hf_pgm_main_cksum, tvb, |
| 933 | | | ptvcursor_current_offset(cursor), 2, pgmhdr_cksum, "Checksum: 0x%04x [correct]", pgmhdr_cksum); |
| 934 | | | } else { |
| 935 | | | hidden_item = proto_tree_add_boolean(pgm_tree, hf_pgm_main_cksum_bad, tvb, |
| 936 | | | ptvcursor_current_offset(cursor), 2, TRUE); |
| 937 | | | PROTO_ITEM_SET_HIDDEN(hidden_item);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
319 | #define PROTO_ITEM_SET_HIDDEN(proto_item) \ |
320 | ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
246 | #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag) |
| |
|
| 938 | | | proto_tree_add_uint_format(pgm_tree, hf_pgm_main_cksum, tvb, |
| 939 | | | ptvcursor_current_offset(cursor), 2, pgmhdr_cksum, "Checksum: 0x%04x [incorrect, should be 0x%04x]", |
| 940 | | | pgmhdr_cksum, in_cksum_shouldbe(pgmhdr_cksum, computed_cksum)); |
| 941 | | | } |
| 942 | | | } else { |
| 943 | | | ptvcursor_add_no_advance(cursor, hf_pgm_main_cksum, 2, FALSE); |
| 944 | | | } |
| 945 | | | } |
| 946 | | | ptvcursor_advance(cursor, 2); |
| 947 | | | |
| 948 | | | ptvcursor_add(cursor, hf_pgm_main_gsi, 6, FALSE); |
| 949 | | | ptvcursor_add(cursor, hf_pgm_main_tsdulen, 2, FALSE); |
| 950 | | | |
| 951 | | | tf = proto_tree_add_text(pgm_tree, tvb, ptvcursor_current_offset(cursor), plen, "%s Packet", pktname); |
| 952 | | | switch(pgmhdr_type) { |
| 953 | | | case PGM_SPM_PCKT: |
| 954 | | | type_tree = proto_item_add_subtree(tf, ett_pgm_spm); |
| 955 | | | ptvcursor_set_tree(cursor, type_tree); |
| 956 | | | |
| 957 | | | ptvcursor_add(cursor, hf_pgm_spm_sqn, 4, FALSE); |
| 958 | | | ptvcursor_add(cursor, hf_pgm_spm_trail, 4, FALSE); |
| 959 | | | ptvcursor_add(cursor, hf_pgm_spm_lead, 4, FALSE); |
| 960 | | | afi = tvb_get_ntohs(tvb, ptvcursor_current_offset(cursor)); |
| 961 | | | ptvcursor_add(cursor, hf_pgm_spm_pathafi, 2, FALSE); |
| 962 | | | ptvcursor_add(cursor, hf_pgm_spm_res, 2, FALSE); |
| 963 | | | |
| 964 | | | switch (afi) { |
| 965 | | | case AFNUM_INET: |
| 966 | | | ptvcursor_add(cursor, hf_pgm_spm_path, 4, FALSE); |
| 967 | | | break; |
| 968 | | | |
| 969 | | | case AFNUM_INET6: |
| 970 | | | ptvcursor_add(cursor, hf_pgm_spm_path6, 16, FALSE); |
| 971 | | | break; |
| 972 | | | |
| 973 | | | default: |
| 974 | | | proto_tree_add_text(type_tree, tvb, ptvcursor_current_offset(cursor), -1, |
| 975 | | | "Can't handle this address format"); |
| 976 | | | return; |
| 977 | | | } |
| 978 | | | break; |
| 979 | | | case PGM_RDATA_PCKT: |
| 980 | | | case PGM_ODATA_PCKT: |
| 981 | | | type_tree = proto_item_add_subtree(tf, ett_pgm_data); |
| 982 | | | ptvcursor_set_tree(cursor, type_tree); |
| 983 | | | |
| 984 | | | ptvcursor_add(cursor, hf_pgm_spm_sqn, 4, FALSE); |
| 985 | | | ptvcursor_add(cursor, hf_pgm_spm_trail, 4, FALSE); |
| 986 | | | break; |
| 987 | | | case PGM_NAK_PCKT: |
| 988 | | | case PGM_NNAK_PCKT: |
| 989 | | | case PGM_NCF_PCKT: |
| 990 | | | type_tree = proto_item_add_subtree(tf, ett_pgm_nak); |
| 991 | | | ptvcursor_set_tree(cursor, type_tree); |
| 992 | | | |
| 993 | | | ptvcursor_add(cursor, hf_pgm_nak_sqn, 4, FALSE); |
| 994 | | | afi = tvb_get_ntohs(tvb, ptvcursor_current_offset(cursor)); |
| 995 | | | ptvcursor_add(cursor, hf_pgm_nak_srcafi, 2, FALSE); |
| 996 | | | ptvcursor_add(cursor, hf_pgm_nak_srcres, 2, FALSE); |
| 997 | | | |
| 998 | | | switch (afi) { |
| 999 | | | case AFNUM_INET: |
| 1000 | | | ptvcursor_add(cursor, hf_pgm_nak_src, 4, FALSE); |
| 1001 | | | break; |
| 1002 | | | |
| 1003 | | | case AFNUM_INET6: |
| 1004 | | | ptvcursor_add(cursor, hf_pgm_nak_src6, 16, FALSE); |
| 1005 | | | break; |
| 1006 | | | |
| 1007 | | | default: |
| 1008 | | | proto_tree_add_text(type_tree, tvb, ptvcursor_current_offset(cursor), -1, |
| 1009 | | | "Can't handle this address format"); |
| 1010 | | | break; |
| 1011 | | | } |
| 1012 | | | |
| 1013 | | | afi = tvb_get_ntohs(tvb, ptvcursor_current_offset(cursor)); |
| 1014 | | | ptvcursor_add(cursor, hf_pgm_nak_grpafi, 2, FALSE); |
| 1015 | | | ptvcursor_add(cursor, hf_pgm_nak_grpres, 2, FALSE); |
| 1016 | | | |
| 1017 | | | switch (afi) { |
| 1018 | | | case AFNUM_INET: |
| 1019 | | | ptvcursor_add(cursor, hf_pgm_nak_grp, 4, FALSE); |
| 1020 | | | break; |
| 1021 | | | |
| 1022 | | | case AFNUM_INET6: |
| 1023 | | | ptvcursor_add(cursor, hf_pgm_nak_grp6, 16, FALSE); |
| 1024 | | | break; |
| 1025 | | | |
| 1026 | | | default: |
| 1027 | | | proto_tree_add_text(type_tree, tvb, ptvcursor_current_offset(cursor), -1, |
| 1028 | | | "Can't handle this address format"); |
| 1029 | | | return; |
| 1030 | | | } |
| 1031 | | | break; |
| 1032 | | | case PGM_POLL_PCKT: |
| 1033 | | | type_tree = proto_item_add_subtree(tf, ett_pgm_poll); |
| 1034 | | | ptvcursor_set_tree(cursor, type_tree); |
| 1035 | | | |
| 1036 | | | ptvcursor_add(cursor, hf_pgm_poll_sqn, 4, FALSE); |
| 1037 | | | ptvcursor_add(cursor, hf_pgm_poll_round, 2, FALSE); |
| 1038 | | | ptvcursor_add(cursor, hf_pgm_poll_subtype, 2, FALSE); |
| 1039 | | | afi = tvb_get_ntohs(tvb, ptvcursor_current_offset(cursor)); |
| 1040 | | | ptvcursor_add(cursor, hf_pgm_poll_pathafi, 2, FALSE); |
| 1041 | | | ptvcursor_add(cursor, hf_pgm_poll_res, 2, FALSE); |
| 1042 | | | |
| 1043 | | | switch (afi) { |
| 1044 | | | case AFNUM_INET: |
| 1045 | | | ptvcursor_add(cursor, hf_pgm_poll_path, 4, FALSE); |
| 1046 | | | break; |
| 1047 | | | |
| 1048 | | | case AFNUM_INET6: |
| 1049 | | | ptvcursor_add(cursor, hf_pgm_poll_path6, 16, FALSE); |
| 1050 | | | break; |
| 1051 | | | |
| 1052 | | | default: |
| 1053 | | | proto_tree_add_text(type_tree, tvb, ptvcursor_current_offset(cursor), -1, |
| 1054 | | | "Can't handle this address format"); |
| 1055 | | | break; |
| 1056 | | | } |
| 1057 | | | |
| 1058 | | | ptvcursor_add(cursor, hf_pgm_poll_backoff_ivl, 4, FALSE); |
| 1059 | | | ptvcursor_add(cursor, hf_pgm_poll_rand_str, 4, FALSE); |
| 1060 | | | ptvcursor_add(cursor, hf_pgm_poll_matching_bmask, 4, FALSE); |
| 1061 | | | break; |
| 1062 | | | case PGM_POLR_PCKT: |
| 1063 | | | type_tree = proto_item_add_subtree(tf, ett_pgm_polr); |
| 1064 | | | ptvcursor_set_tree(cursor, type_tree); |
| 1065 | | | |
| 1066 | | | ptvcursor_add(cursor, hf_pgm_polr_sqn, 4, FALSE); |
| 1067 | | | ptvcursor_add(cursor, hf_pgm_polr_round, 2, FALSE); |
| 1068 | | | ptvcursor_add(cursor, hf_pgm_polr_res, 2, FALSE); |
| 1069 | | | break; |
| 1070 | | | case PGM_ACK_PCKT: |
| 1071 | | | type_tree = proto_item_add_subtree(tf, ett_pgm_ack); |
| 1072 | | | ptvcursor_set_tree(cursor, type_tree); |
| 1073 | | | |
| 1074 | | | ptvcursor_add(cursor, hf_pgm_ack_sqn, 4, FALSE); |
| 1075 | | | ptvcursor_add(cursor, hf_pgm_ack_bitmap, 4, FALSE); |
| 1076 | | | break; |
| 1077 | | | } |
| 1078 | | | |
| 1079 | | | if (pgmhdr_opts & PGM_OPT) |
| 1080 | | | dissect_pgmopts(cursor, pktname); |
| 1081 | | | |
| 1082 | | | if (isdata) |
| 1083 | | | decode_pgm_ports(tvb, ptvcursor_current_offset(cursor), pinfo, tree, pgmhdr_sport, pgmhdr_dport); |
| 1084 | | | } |
| 1085 | | | } |
| |