(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-bssgp.c) |
| |
| 1281 | | | decode_mobile_identity(bssgp_ie_t *ie, build_info_t *bi, int ie_start_offset) { |
| 1282 | | | #define MAX_NUM_IMSI_DIGITS 15 |
| 1283 | | | const guint8 MASK_ODD_EVEN_INDICATION = 0x08; |
| 1284 | | | const guint8 MASK_TYPE_OF_IDENTITY = 0x07; |
| 1285 | | | const guint8 ODD = 1; |
| 1286 | | | proto_item *ti = NULL, *pi; |
| 1287 | | | proto_tree *tf = NULL; |
| 1288 | | | guint8 data, odd_even, type, num_digits, i; |
| 1289 | | | int hf_id; |
| 1290 | | | guint32 tmsi; |
| 1291 | | | guint8 digits[MAX_NUM_IMSI_DIGITS]; |
| 1292 | | | char digits_str[MAX_NUM_IMSI_DIGITS + 1]; |
| 1293 | | | |
| 1294 | | | static const value_string tab_type_of_identity[] = { |
| 1295 | | | { BSSGP_MOBILE_IDENTITY_TYPE_IMSI, "IMSI" }, |
| 1296 | | | { BSSGP_MOBILE_IDENTITY_TYPE_IMEI, "IMEI" }, |
| 1297 | | | { BSSGP_MOBILE_IDENTITY_TYPE_IMEISV, "IMEISV" }, |
| 1298 | | | { BSSGP_MOBILE_IDENTITY_TYPE_TMSI_PTMSI, "TMSI//P-TMSI" }, |
| 1299 | | | { BSSGP_MOBILE_IDENTITY_TYPE_NO_IDENTITY, "No identity" }, |
| 1300 | | | { 0, NULL }, |
| 1301 | | | |
| 1302 | | | }; |
| 1303 | | | |
| 1304 | | | digits_str[0] = '\0'; |
| 1305 | | | |
| 1306 | | | if (bi->bssgp_tree) { |
| 1307 | | | ti = bssgp_proto_tree_add_ie(ie, bi, ie_start_offset); |
| 1308 | | | tf = proto_item_add_subtree(ti, ett_bssgp_mobile_identity); |
| 1309 | | | } |
| 1310 | | | data = tvb_get_guint8(bi->tvb, bi->offset); |
| 1311 | | | odd_even = get_masked_guint8(data, MASK_ODD_EVEN_INDICATION); |
| 1312 | | | |
| 1313 | | | if (bi->bssgp_tree) { |
| 1314 | | | pi = proto_tree_add_bitfield8(tf, bi->tvb, bi->offset, |
| 1315 | | | MASK_ODD_EVEN_INDICATION); |
| 1316 | | | proto_item_append_text(pi, "Odd/Even Indication: %s number of identity digits%s", |
| 1317 | | | odd_even == ODD ? "Odd" : "Even", |
| 1318 | | | odd_even == ODD ? "" : " and also when the TMSI/P_TMSI is used"); |
| 1319 | | | } |
| 1320 | | | type = get_masked_guint8(data, MASK_TYPE_OF_IDENTITY); |
| 1321 | | | |
| 1322 | | | if (bi->bssgp_tree) { |
| 1323 | | | pi = proto_tree_add_bitfield8(tf, bi->tvb, bi->offset, |
| 1324 | | | MASK_TYPE_OF_IDENTITY); |
| 1325 | | | proto_item_append_text(pi, "Type of Identity: %s", |
| 1326 | | | val_to_str(type, tab_type_of_identity, |
| 1327 | | | "Reserved")); |
| 1328 | | | } |
| 1329 | | | bi->offset++; |
| 1330 | | | switch (type) { |
| 1331 | | | case BSSGP_MOBILE_IDENTITY_TYPE_IMSI: |
| 1332 | | | case BSSGP_MOBILE_IDENTITY_TYPE_IMEI: |
| 1333 | | | case BSSGP_MOBILE_IDENTITY_TYPE_IMEISV: |
| 1334 | | | num_digits = 1 + (ie->value_length - 1) * 2; |
| 1335 | | | if (odd_even != ODD ) num_digits--; |
| 1336 | | | if (num_digits > MAX_NUM_IMSI_DIGITS) THROW(ReportedBoundsError);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
223 | #define THROW(x) \ |
224 | except_throw(XCEPT_GROUP_WIRESHARK, (x), NULL) |
| |
|
| 1337 | | | |
| 1338 | | | i = 0; |
| 1339 | | | digits[i] = get_masked_guint8(data, BSSGP_MASK_LEFT_OCTET_HALF); |
| 1340 | | | |
| 1341 | | | i++; |
| 1342 | | | while (TRUE) { |
| 1343 | | | data = tvb_get_guint8(bi->tvb, bi->offset); |
| 1344 | | | |
| 1345 | | | digits[i] = get_masked_guint8(data, BSSGP_MASK_RIGHT_OCTET_HALF); |
| 1346 | | | i++; |
| 1347 | | | if (i >= num_digits) break; |
| 1348 | | | |
| 1349 | | | digits[i] = get_masked_guint8(data, BSSGP_MASK_LEFT_OCTET_HALF); |
| 1350 | | | i++; |
| 1351 | | | if (i >= num_digits) break; |
| 1352 | | | bi->offset++; |
| 1353 | | | } |
| 1354 | | | bi->offset++; |
| 1355 | | | |
| 1356 | | | if (bi->bssgp_tree) { |
| 1357 | | | proto_item_append_text(ti, ": "); |
| 1358 | | | for (i = 0; i < num_digits; i++) { |
| 1359 | | | proto_item_append_text(ti, "%u", digits[i]); |
| 1360 | | | g_snprintf(&digits_str[i], 2, "%u", digits[i]); |
| 1361 | | | } |
| 1362 | | | switch (type) { |
| 1363 | | | case BSSGP_MOBILE_IDENTITY_TYPE_IMSI: |
| 1364 | | | hf_id = hf_bssgp_imsi; |
| 1365 | | | break; |
| 1366 | | | case BSSGP_MOBILE_IDENTITY_TYPE_IMEI: |
| 1367 | | | hf_id = hf_bssgp_imei; |
| 1368 | | | break; |
| 1369 | | | case BSSGP_MOBILE_IDENTITY_TYPE_IMEISV: |
| 1370 | | | hf_id = hf_bssgp_imeisv; |
| 1371 | | | break; |
| 1372 | | | default: |
| 1373 | | | DISSECTOR_ASSERT_NOT_REACHED();
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
131 | #define DISSECTOR_ASSERT_NOT_REACHED() \ |
132 | (REPORT_DISSECTOR_BUG( \ |
133 | ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \ |
134 | __FILE__, __LINE__))) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
106 | #define REPORT_DISSECTOR_BUG(message) \ |
107 | ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) ? \ |
108 | abort() : \ |
109 | THROW_MESSAGE(DissectorError, message)) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
226 | #define THROW_MESSAGE(x, y) \ |
227 | except_throw(XCEPT_GROUP_WIRESHARK, (x), (y)) |
| |
|
| 1374 | | | hf_id = -1; |
Unreachable Computation
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 1375 | | | break; |
| 1376 | | | } |
| 1377 | | | if (tf) |
| 1378 | | | proto_tree_add_string(tf, hf_id, bi->tvb, ie_start_offset + 2, ((num_digits/2)+1), digits_str); |
| 1379 | | | |
| 1380 | | | } |
| 1381 | | | if (check_col(bi->pinfo->cinfo, COL_INFO)) { |
| 1382 | | | col_append_sep_fstr(bi->pinfo->cinfo, COL_INFO, BSSGP_SEP, "%s %s", |
| 1383 | | | val_to_str(type, tab_type_of_identity, |
| 1384 | | | "Mobile identity unknown"), |
| 1385 | | | digits_str); |
| 1386 | | | } |
| 1387 | | | break; |
| 1388 | | | case BSSGP_MOBILE_IDENTITY_TYPE_TMSI_PTMSI: |
| 1389 | | | tmsi = tvb_get_ntohl(bi->tvb, bi->offset); |
| 1390 | | | if (check_col(bi->pinfo->cinfo, COL_INFO)) { |
| 1391 | | | col_append_sep_fstr(bi->pinfo->cinfo, COL_INFO, BSSGP_SEP, |
| 1392 | | | "TMSI/P-TMSI %0x04x", tmsi); |
| 1393 | | | } |
| 1394 | | | if (bi->bssgp_tree) { |
| 1395 | | | proto_tree_add_item(tf, hf_bssgp_tmsi_ptmsi, bi->tvb, bi->offset, 4, |
| 1396 | | | BSSGP_LITTLE_ENDIAN); |
| 1397 | | | proto_item_append_text(ti, ": %#04x", tmsi); |
| 1398 | | | } |
| 1399 | | | decode_nri(tf, bi, tmsi); |
| 1400 | | | bi->offset += 4; |
| 1401 | | | break; |
| 1402 | | | default: |
| 1403 | | | ; |
| 1404 | | | } |
| 1405 | | | #undef MAX_NUM_IMSI_DIGITS |
| 1406 | | | } |
| |