(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/catapult_dct2000.c) |
| |
| 826 | | | gboolean parse_line(gint line_length, gint *seconds, gint *useconds, |
| 827 | | | long *before_time_offset, long *after_time_offset, |
| 828 | | | long *data_offset, gint *data_chars, |
| 829 | | | packet_direction_t *direction, |
| 830 | | | int *encap) |
| 831 | | | { |
| 832 | | | int n = 0; |
| 833 | | | int port_digits = 0; |
| 834 | | | char port_number_string[MAX_PORT_DIGITS+1]; |
| 835 | | | int variant_digits = 0; |
| 836 | | | int variant = 1; |
| 837 | | | int protocol_chars = 0; |
| 838 | | | int outhdr_chars = 0; |
| 839 | | | |
| 840 | | | char seconds_buff[MAX_SECONDS_CHARS+1]; |
| 841 | | | int seconds_chars; |
| 842 | | | char subsecond_decimals_buff[MAX_SUBSECOND_DECIMALS+1]; |
| 843 | | | int subsecond_decimals_chars; |
| 844 | | | int skip_first_byte = FALSE; |
| 845 | | | |
| 846 | | | gboolean = FALSE; |
| 847 | | | |
| 848 | | | |
| 849 | | | for (n=0; linebuff[n] != '.' && (n < MAX_CONTEXT_NAME) && (n+1 < line_length); n++) |
| 850 | | | { |
| 851 | | | if (!isalnum((guchar)linebuff[n]) && (linebuff[n] != '_') && (linebuff[n] != '-')) |
| 852 | | | { |
| 853 | | | return FALSE; |
| 854 | | | } |
| 855 | | | context_name[n] = linebuff[n]; |
| 856 | | | } |
| 857 | | | if (n == MAX_CONTEXT_NAME || (n+1 >= line_length)) |
| 858 | | | { |
| 859 | | | return FALSE; |
| 860 | | | } |
| 861 | | | |
| 862 | | | |
| 863 | | | if (linebuff[n] != '.') |
| 864 | | | { |
| 865 | | | return FALSE; |
| 866 | | | } |
| 867 | | | context_name[n] = '\0'; |
| 868 | | | |
| 869 | | | n++; |
| 870 | | | |
| 871 | | | |
| 872 | | | |
| 873 | | | for (port_digits = 0; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 874 | | | (linebuff[n] != '/') && (port_digits <= MAX_PORT_DIGITS) && (n+1 < line_length); |
| 875 | | | n++, port_digits++) |
| 876 | | | { |
| 877 | | | if (!isdigit((guchar)linebuff[n])) |
| 878 | | | { |
| 879 | | | return FALSE; |
| 880 | | | } |
| 881 | | | port_number_string[port_digits] = linebuff[n]; |
| 882 | | | } |
| 883 | | | if (port_digits > MAX_PORT_DIGITS || (n+1 >= line_length)) |
| 884 | | | { |
| 885 | | | return FALSE; |
| 886 | | | } |
| 887 | | | |
| 888 | | | |
| 889 | | | if (linebuff[n] != '/') |
| 890 | | | { |
| 891 | | | return FALSE; |
| 892 | | | } |
| 893 | | | port_number_string[port_digits] = '\0'; |
| 894 | | | context_port = atoi(port_number_string); |
| 895 | | | |
| 896 | | | n++; |
| 897 | | | |
| 898 | | | |
| 899 | | | |
| 900 | | | for (protocol_chars = 0; |
| 901 | | | (linebuff[n] != '/') && (protocol_chars < MAX_PROTOCOL_NAME) && (n < line_length); |
| 902 | | | n++, protocol_chars++) |
| 903 | | | { |
| 904 | | | if (!isalnum((guchar)linebuff[n]) && linebuff[n] != '_') |
| 905 | | | { |
| 906 | | | return FALSE; |
| 907 | | | } |
| 908 | | | protocol_name[protocol_chars] = linebuff[n]; |
| 909 | | | } |
| 910 | | | if (protocol_chars == MAX_PROTOCOL_NAME || n >= line_length) |
| 911 | | | { |
| 912 | | | |
| 913 | | | return FALSE; |
| 914 | | | } |
| 915 | | | protocol_name[protocol_chars] = '\0'; |
| 916 | | | |
| 917 | | | |
| 918 | | | if (linebuff[n] != '/') |
| 919 | | | { |
| 920 | | | return FALSE; |
| 921 | | | } |
| 922 | | | |
| 923 | | | n++; |
| 924 | | | |
| 925 | | | |
| 926 | | | |
| 927 | | | for (variant_digits = 0; |
| 928 | | | (isdigit((guchar)linebuff[n])) && (variant_digits <= MAX_VARIANT_DIGITS) && (n+1 < line_length); |
| 929 | | | n++, variant_digits++) |
| 930 | | | { |
| 931 | | | if (!isdigit((guchar)linebuff[n])) |
| 932 | | | { |
| 933 | | | return FALSE; |
| 934 | | | } |
| 935 | | | variant_name[variant_digits] = linebuff[n]; |
| 936 | | | } |
| 937 | | | if (variant_digits > MAX_VARIANT_DIGITS || (n+1 >= line_length)) |
| 938 | | | { |
| 939 | | | return FALSE; |
| 940 | | | } |
| 941 | | | if (variant_digits > 0) |
| 942 | | | { |
| 943 | | | variant_name[variant_digits] = '\0'; |
| 944 | | | variant = atoi(variant_name); |
| 945 | | | } |
| 946 | | | else |
| 947 | | | { |
| 948 | | | g_strlcpy(variant_name, "1", MAX_VARIANT_DIGITS+1); |
| 949 | | | } |
| 950 | | | |
| 951 | | | |
| 952 | | | |
| 953 | | | outhdr_name[0] = '\0'; |
| 954 | | | if (linebuff[n] == ',') |
| 955 | | | { |
| 956 | | | |
| 957 | | | n++; |
| 958 | | | |
| 959 | | | for (outhdr_chars = 0; |
| 960 | | | (isdigit((guchar)linebuff[n]) || linebuff[n] == ',') && |
| 961 | | | (outhdr_chars <= MAX_OUTHDR_NAME) && (n+1 < line_length); |
| 962 | | | n++, outhdr_chars++) |
| 963 | | | { |
| 964 | | | if (!isdigit((guchar)linebuff[n]) && (linebuff[n] != ',')) |
| 965 | | | { |
| 966 | | | return FALSE; |
| 967 | | | } |
| 968 | | | outhdr_name[outhdr_chars] = linebuff[n]; |
| 969 | | | } |
| 970 | | | if (outhdr_chars > MAX_OUTHDR_NAME || (n+1 >= line_length)) |
| 971 | | | { |
| 972 | | | return FALSE; |
| 973 | | | } |
| 974 | | | |
| 975 | | | outhdr_name[outhdr_chars] = '\0'; |
| 976 | | | } |
| 977 | | | |
| 978 | | | |
| 979 | | | |
| 980 | | | |
| 981 | | | |
| 982 | | | |
| 983 | | | |
| 984 | | | if ((strcmp(protocol_name, "ip") == 0) || |
| 985 | | | (strcmp(protocol_name, "sctp") == 0) || |
| 986 | | | (strcmp(protocol_name, "gre") == 0) || |
| 987 | | | (strcmp(protocol_name, "mipv6") == 0) || |
| 988 | | | (strcmp(protocol_name, "igmp") == 0)) |
| 989 | | | { |
| 990 | | | *encap = WTAP_ENCAP_RAW_IP; |
| 991 | | | } |
| 992 | | | else |
| 993 | | | |
| 994 | | | |
| 995 | | | if ((strcmp(protocol_name, "fp") == 0) || |
| 996 | | | (strcmp(protocol_name, "fp_r4") == 0) || |
| 997 | | | (strcmp(protocol_name, "fp_r5") == 0) || |
| 998 | | | (strcmp(protocol_name, "fp_r6") == 0) || |
| 999 | | | (strcmp(protocol_name, "fp_r7") == 0)) |
| 1000 | | | { |
| 1001 | | | if ((variant > 256) && (variant % 256 == 3)) |
| 1002 | | | { |
| 1003 | | | |
| 1004 | | | *encap = 0; |
| 1005 | | | } |
| 1006 | | | else |
| 1007 | | | { |
| 1008 | | | |
| 1009 | | | *encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED; |
| 1010 | | | = TRUE; |
| 1011 | | | } |
| 1012 | | | } |
| 1013 | | | else if (strcmp(protocol_name, "fpiur_r5") == 0) |
| 1014 | | | { |
| 1015 | | | |
| 1016 | | | *encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED; |
| 1017 | | | = TRUE; |
| 1018 | | | } |
| 1019 | | | |
| 1020 | | | |
| 1021 | | | else |
| 1022 | | | if (strcmp(protocol_name, "ppp") == 0) |
| 1023 | | | { |
| 1024 | | | *encap = WTAP_ENCAP_PPP; |
| 1025 | | | } |
| 1026 | | | else |
| 1027 | | | if (strcmp(protocol_name, "isdn_l3") == 0) |
| 1028 | | | { |
| 1029 | | | |
| 1030 | | | skip_first_byte = TRUE; |
| 1031 | | | *encap = WTAP_ENCAP_ISDN; |
| 1032 | | | } |
| 1033 | | | else |
| 1034 | | | if (strcmp(protocol_name, "isdn_l2") == 0) |
| 1035 | | | { |
| 1036 | | | *encap = WTAP_ENCAP_ISDN; |
| 1037 | | | } |
| 1038 | | | else |
| 1039 | | | if (strcmp(protocol_name, "ethernet") == 0) |
| 1040 | | | { |
| 1041 | | | *encap = WTAP_ENCAP_ETHERNET; |
| 1042 | | | } |
| 1043 | | | else |
| 1044 | | | if ((strcmp(protocol_name, "saalnni_sscop") == 0) || |
| 1045 | | | (strcmp(protocol_name, "saaluni_sscop") == 0)) |
| 1046 | | | { |
| 1047 | | | *encap = DCT2000_ENCAP_SSCOP; |
| 1048 | | | } |
| 1049 | | | else |
| 1050 | | | if (strcmp(protocol_name, "frelay_l2") == 0) |
| 1051 | | | { |
| 1052 | | | *encap = WTAP_ENCAP_FRELAY; |
| 1053 | | | } |
| 1054 | | | else |
| 1055 | | | if (strcmp(protocol_name, "ss7_mtp2") == 0) |
| 1056 | | | { |
| 1057 | | | *encap = DCT2000_ENCAP_MTP2; |
| 1058 | | | } |
| 1059 | | | else |
| 1060 | | | if ((strcmp(protocol_name, "nbap") == 0) || |
| 1061 | | | (strcmp(protocol_name, "nbap_r4") == 0) || |
| 1062 | | | (strncmp(protocol_name, "nbap_sscfuni", strlen("nbap_sscfuni")) == 0)) |
| 1063 | | | { |
| 1064 | | | |
| 1065 | | | *encap = DCT2000_ENCAP_NBAP; |
| 1066 | | | } |
| 1067 | | | else |
| 1068 | | | { |
| 1069 | | | |
| 1070 | | | |
| 1071 | | | *encap = DCT2000_ENCAP_UNHANDLED; |
| 1072 | | | } |
| 1073 | | | |
| 1074 | | | |
| 1075 | | | |
| 1076 | | | if () |
| 1077 | | | { |
| 1078 | | | int = 0; |
| 1079 | | | |
| 1080 | | | |
| 1081 | | | for (; (linebuff[n] != '$') && (n+1 < line_length); n++); |
| 1082 | | | |
| 1083 | | | n++; |
| 1084 | | | if (n+1 >= line_length) |
| 1085 | | | { |
| 1086 | | | return FALSE; |
| 1087 | | | } |
| 1088 | | | |
| 1089 | | | |
| 1090 | | | for (; |
| 1091 | | | ((linebuff[n] >= '0') && (linebuff[n] <= '?') && |
| 1092 | | | (n < line_length) && |
| 1093 | | | ( < )); |
| 1094 | | | n++, ++) |
| 1095 | | | { |
| 1096 | | | [] = linebuff[n]; |
| 1097 | | | |
| 1098 | | | if (!isdigit((guchar)linebuff[n])) |
| 1099 | | | { |
| 1100 | | | [] = 'a' + (linebuff[n] - '9') -1; |
| 1101 | | | } |
| 1102 | | | } |
| 1103 | | | |
| 1104 | | | if ( != || n >= line_length) |
| 1105 | | | { |
| 1106 | | | return FALSE; |
| 1107 | | | } |
| 1108 | | | } |
| 1109 | | | |
| 1110 | | | |
| 1111 | | | |
| 1112 | | | for (; (linebuff[n] != ' ') && (n+1 < line_length); n++); |
| 1113 | | | if (n+1 >= line_length) |
| 1114 | | | { |
| 1115 | | | return FALSE; |
| 1116 | | | } |
| 1117 | | | |
| 1118 | | | n++; |
| 1119 | | | |
| 1120 | | | |
| 1121 | | | if (linebuff[n] == 's') |
| 1122 | | | { |
| 1123 | | | *direction = sent; |
| 1124 | | | } |
| 1125 | | | else |
| 1126 | | | if (linebuff[n] == 'r') |
| 1127 | | | { |
| 1128 | | | *direction = received; |
| 1129 | | | } |
| 1130 | | | else |
| 1131 | | | { |
| 1132 | | | return FALSE; |
| 1133 | | | } |
| 1134 | | | |
| 1135 | | | n++; |
| 1136 | | | |
| 1137 | | | |
| 1138 | | | |
| 1139 | | | |
| 1140 | | | |
| 1141 | | | |
| 1142 | | | |
| 1143 | | | for (; !isdigit((guchar)linebuff[n]) && (n < line_length); n++); |
| 1144 | | | if (n >= line_length) |
| 1145 | | | { |
| 1146 | | | return FALSE; |
| 1147 | | | } |
| 1148 | | | |
| 1149 | | | *before_time_offset = n; |
| 1150 | | | |
| 1151 | | | |
| 1152 | | | for (seconds_chars = 0; |
| 1153 | | | (linebuff[n] != '.') && |
| 1154 | | | (seconds_chars <= MAX_SECONDS_CHARS) && |
| 1155 | | | (n < line_length); |
| 1156 | | | n++, seconds_chars++) |
| 1157 | | | { |
| 1158 | | | if (!isdigit((guchar)linebuff[n])) |
| 1159 | | | { |
| 1160 | | | |
| 1161 | | | return FALSE; |
| 1162 | | | } |
| 1163 | | | seconds_buff[seconds_chars] = linebuff[n]; |
| 1164 | | | } |
| 1165 | | | if (seconds_chars > MAX_SECONDS_CHARS || n >= line_length) |
| 1166 | | | { |
| 1167 | | | |
| 1168 | | | return FALSE; |
| 1169 | | | } |
| 1170 | | | |
| 1171 | | | |
| 1172 | | | seconds_buff[seconds_chars] = '\0'; |
| 1173 | | | *seconds = atoi(seconds_buff); |
| 1174 | | | |
| 1175 | | | |
| 1176 | | | if (linebuff[n] != '.') |
| 1177 | | | { |
| 1178 | | | return FALSE; |
| 1179 | | | } |
| 1180 | | | |
| 1181 | | | n++; |
| 1182 | | | |
| 1183 | | | |
| 1184 | | | for (subsecond_decimals_chars = 0; |
| 1185 | | | (linebuff[n] != ' ') && |
| 1186 | | | (subsecond_decimals_chars <= MAX_SUBSECOND_DECIMALS) && |
| 1187 | | | (n < line_length); |
| 1188 | | | n++, subsecond_decimals_chars++) |
| 1189 | | | { |
| 1190 | | | if (!isdigit((guchar)linebuff[n])) |
| 1191 | | | { |
| 1192 | | | return FALSE; |
| 1193 | | | } |
| 1194 | | | subsecond_decimals_buff[subsecond_decimals_chars] = linebuff[n]; |
| 1195 | | | } |
| 1196 | | | if (subsecond_decimals_chars > MAX_SUBSECOND_DECIMALS || n >= line_length) |
| 1197 | | | { |
| 1198 | | | |
| 1199 | | | return FALSE; |
| 1200 | | | } |
| 1201 | | | |
| 1202 | | | subsecond_decimals_buff[subsecond_decimals_chars] = '\0'; |
| 1203 | | | *useconds = atoi(subsecond_decimals_buff) * 100; |
| 1204 | | | |
| 1205 | | | |
| 1206 | | | if (linebuff[n] != ' ') |
| 1207 | | | { |
| 1208 | | | return FALSE; |
| 1209 | | | } |
| 1210 | | | |
| 1211 | | | *after_time_offset = n; |
| 1212 | | | |
| 1213 | | | |
| 1214 | | | for (; (linebuff[n] != '$') && (n+1 < line_length); n++); |
| 1215 | | | if (n+1 >= line_length) |
| 1216 | | | { |
| 1217 | | | return FALSE; |
| 1218 | | | } |
| 1219 | | | |
| 1220 | | | n++; |
| 1221 | | | |
| 1222 | | | |
| 1223 | | | *data_offset = n; |
| 1224 | | | |
| 1225 | | | |
| 1226 | | | *data_chars = line_length - n; |
| 1227 | | | |
| 1228 | | | |
| 1229 | | | if (skip_first_byte) |
| 1230 | | | { |
| 1231 | | | *data_offset += 2; |
| 1232 | | | *data_chars -= 2; |
| 1233 | | | } |
| 1234 | | | |
| 1235 | | | |
| 1236 | | | return TRUE; |
| 1237 | | | } |
| |