(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-cops.c) |
| |
| 1381 | | | static int dissect_cops_pr_object_data(tvbuff_t *tvb, packet_info *pinfo, guint32 offset, proto_tree *tree, |
| 1382 | | | guint8 s_num, guint8 s_type, int len, |
| 1383 | | | oid_info_t** oid_info_p, guint32** pprid_subids, guint* pprid_subids_len) { |
| 1384 | | | proto_item *ti; |
| 1385 | | | proto_tree *asn_tree, *gperror_tree, *cperror_tree; |
| 1386 | | | guint16 gperror=0, gperror_sub=0, cperror=0, cperror_sub=0; |
| 1387 | | | asn1_ctx_t actx; |
| 1388 | | | |
| 1389 | | | memset(&actx,0,sizeof(actx)); |
| 1390 | | | actx.pinfo = pinfo; |
| 1391 | | | |
| 1392 | | | switch (s_num){ |
| 1393 | | | case COPS_OBJ_PPRID: { |
| 1394 | | | tvbuff_t* oid_tvb = NULL; |
| 1395 | | | |
| 1396 | | | if (s_type != 1) |
| 1397 | | | break; |
| 1398 | | | |
| 1399 | | | ti = proto_tree_add_text(tree, tvb, offset, len, "Contents:"); |
| 1400 | | | asn_tree = proto_item_add_subtree(ti, ett_cops_asn1); |
| 1401 | | | |
| 1402 | | | offset = dissect_ber_object_identifier(FALSE, &actx, asn_tree, tvb, offset, hf_cops_pprid_oid, &oid_tvb); |
Ignored Return Value
The return value of dissect_ber_object_identifier() 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 dissect_ber_object_identifier() 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 dissect_ber_object_identifier() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 1403 | | | |
| 1404 | | | if (oid_tvb) { |
Event 2:
Taking true branch. oid_tvb evaluates to true.
hide
|
|
| 1405 | | | guint encoid_len = tvb_length_remaining(oid_tvb,0); |
| 1406 | | | guint8* encoid = ep_tvb_memdup(oid_tvb,0,encoid_len); |
| 1407 | | | |
| 1408 | | | (*pprid_subids_len) = oid_encoded2subid(encoid, encoid_len, pprid_subids); |
| 1409 | | | } |
| 1410 | | | break; |
| 1411 | | | } |
| 1412 | | | case COPS_OBJ_PRID: { |
| 1413 | | | guint32* subids; |
| 1414 | | | guint subids_len; |
| 1415 | | | guint matched; |
| 1416 | | | guint left; |
| 1417 | | | gint8 ber_class; |
| 1418 | | | gboolean ber_pc; |
| 1419 | | | gint32 ber_tag; |
| 1420 | | | guint encoid_len; |
| 1421 | | | guint8* encoid; |
| 1422 | | | oid_info_t* oid_info; |
| 1423 | | | |
| 1424 | | | if (s_type != 1) break; |
| 1425 | | | |
| 1426 | | | ti=proto_tree_add_text(tree, tvb, offset, len, "Contents:"); |
| 1427 | | | asn_tree = proto_item_add_subtree(ti, ett_cops_asn1); |
| 1428 | | | |
| 1429 | | | offset = get_ber_identifier(tvb, offset, &ber_class, &ber_pc, &ber_tag); |
| 1430 | | | offset = get_ber_length(tvb, offset, &encoid_len, NULL); |
| 1431 | | | |
| 1432 | | | |
| 1433 | | | |
| 1434 | | | encoid = ep_tvb_memdup(tvb,offset,encoid_len); |
| 1435 | | | |
| 1436 | | | if (*pprid_subids) { |
| 1437 | | | |
| 1438 | | | subids_len = redecode_oid(*pprid_subids, *pprid_subids_len, encoid, encoid_len, &subids); |
| 1439 | | | encoid_len = oid_subid2encoded(subids_len, subids, &encoid); |
| 1440 | | | } else { |
| 1441 | | | subids_len = oid_encoded2subid(encoid, encoid_len, &subids); |
| 1442 | | | } |
| 1443 | | | |
| 1444 | | | proto_tree_add_oid(asn_tree,hf_cops_prid_oid,tvb,offset,encoid_len,encoid); |
| 1445 | | | |
| 1446 | | | oid_info = oid_get(subids_len, subids, &matched, &left); |
| 1447 | | | |
| 1448 | | | |
| 1449 | | | |
| 1450 | | | |
| 1451 | | | |
| 1452 | | | |
| 1453 | | | |
| 1454 | | | if (left <= 1 && oid_info->kind == OID_KIND_ROW) { |
| 1455 | | | *oid_info_p = oid_info; |
| 1456 | | | } else { |
| 1457 | | | *oid_info_p = NULL; |
| 1458 | | | } |
| 1459 | | | |
| 1460 | | | break; |
| 1461 | | | } |
| 1462 | | | case COPS_OBJ_EPD: { |
| 1463 | | | oid_info_t* oid_info; |
| 1464 | | | guint end_offset = offset + len; |
| 1465 | | | |
| 1466 | | | if (s_type != 1) break; |
| 1467 | | | |
| 1468 | | | ti = proto_tree_add_text(tree, tvb, offset, len, "Contents:"); |
| 1469 | | | asn_tree = proto_item_add_subtree(ti, ett_cops_asn1); |
| 1470 | | | |
| 1471 | | | |
| 1472 | | | |
| 1473 | | | |
| 1474 | | | |
| 1475 | | | |
| 1476 | | | |
| 1477 | | | |
| 1478 | | | |
| 1479 | | | |
| 1480 | | | if(*oid_info_p) { |
| 1481 | | | if ((*oid_info_p)->kind == OID_KIND_ROW) { |
| 1482 | | | oid_info = emem_tree_lookup32((*oid_info_p)->children,1); |
| 1483 | | | } else { |
| 1484 | | | oid_info = NULL; |
| 1485 | | | } |
| 1486 | | | } else { |
| 1487 | | | oid_info = NULL; |
| 1488 | | | } |
| 1489 | | | |
| 1490 | | | |
| 1491 | | | while(offset < end_offset) { |
| 1492 | | | gint8 ber_class; |
| 1493 | | | gboolean ber_pc; |
| 1494 | | | gint32 ber_tag; |
| 1495 | | | guint32 ber_length; |
| 1496 | | | gboolean ber_ind; |
| 1497 | | | |
| 1498 | | | offset = get_ber_identifier(tvb, offset, &ber_class, &ber_pc, &ber_tag); |
| 1499 | | | offset = get_ber_length(tvb, offset, &ber_length, &ber_ind); |
| 1500 | | | |
| 1501 | | | if (oid_info) { |
| 1502 | | | |
| 1503 | | | |
| 1504 | | | |
| 1505 | | | |
| 1506 | | | |
| 1507 | | | |
| 1508 | | | |
| 1509 | | | |
| 1510 | | | |
| 1511 | | | |
| 1512 | | | |
| 1513 | | | |
| 1514 | | | proto_tree_add_item(asn_tree,oid_info->value_hfid,tvb,offset,ber_length,FALSE); |
| 1515 | | | |
| 1516 | | | oid_info = emem_tree_lookup32((*oid_info_p)->children,oid_info->subid+1); |
| 1517 | | | } else { |
| 1518 | | | int hfid = cops_tag_cls2syntax( ber_tag, ber_class ); |
| 1519 | | | proto_tree_add_item(asn_tree,hfid,tvb,offset,ber_length,FALSE); |
| 1520 | | | } |
| 1521 | | | |
| 1522 | | | offset += ber_length; |
| 1523 | | | } |
| 1524 | | | |
| 1525 | | | (*oid_info_p) = NULL; |
| 1526 | | | break; |
| 1527 | | | } |
| 1528 | | | case COPS_OBJ_ERRPRID: { |
| 1529 | | | if (s_type != 1) break; |
| 1530 | | | |
| 1531 | | | ti = proto_tree_add_text(tree, tvb, offset, len, "Contents:"); |
| 1532 | | | asn_tree = proto_item_add_subtree(ti, ett_cops_asn1); |
| 1533 | | | |
| 1534 | | | offset = dissect_ber_object_identifier(FALSE, &actx, asn_tree, tvb, offset, hf_cops_errprid_oid, NULL); |
| 1535 | | | |
| 1536 | | | break; |
| 1537 | | | } |
| 1538 | | | case COPS_OBJ_GPERR: |
| 1539 | | | if (s_type != 1) |
| 1540 | | | break; |
| 1541 | | | |
| 1542 | | | gperror = tvb_get_ntohs(tvb, offset); |
| 1543 | | | gperror_sub = tvb_get_ntohs(tvb, offset + 2); |
| 1544 | | | ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: Error-Code: %s, Error Sub-code: 0x%04x", |
| 1545 | | | val_to_str(gperror, cops_gperror_vals, "<Unknown value>"), gperror_sub); |
| 1546 | | | gperror_tree = proto_item_add_subtree(ti, ett_cops_gperror); |
| 1547 | | | proto_tree_add_uint(gperror_tree, hf_cops_gperror, tvb, offset, 2, gperror); |
| 1548 | | | offset += 2; |
| 1549 | | | if (gperror == 13) { |
| 1550 | | | proto_tree_add_text(gperror_tree, tvb, offset, 2, "Error Sub-code: " |
| 1551 | | | "Unknown object's C-Num %u, C-Type %u", |
| 1552 | | | tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset + 1)); |
| 1553 | | | } else |
| 1554 | | | proto_tree_add_uint(gperror_tree, hf_cops_gperror_sub, tvb, offset, 2, gperror_sub); |
| 1555 | | | |
| 1556 | | | break; |
| 1557 | | | case COPS_OBJ_CPERR: |
| 1558 | | | if (s_type != 1) |
| 1559 | | | break; |
| 1560 | | | |
| 1561 | | | cperror = tvb_get_ntohs(tvb, offset); |
| 1562 | | | cperror_sub = tvb_get_ntohs(tvb, offset + 2); |
| 1563 | | | ti = proto_tree_add_text(tree, tvb, offset, 4, "Contents: Error-Code: %s, Error Sub-code: 0x%04x", |
| 1564 | | | val_to_str(cperror, cops_cperror_vals, "<Unknown value>"), cperror_sub); |
| 1565 | | | cperror_tree = proto_item_add_subtree(ti, ett_cops_cperror); |
| 1566 | | | proto_tree_add_uint(cperror_tree, hf_cops_cperror, tvb, offset, 2, cperror); |
| 1567 | | | offset += 2; |
| 1568 | | | if (cperror == 13) { |
| 1569 | | | proto_tree_add_text(cperror_tree, tvb, offset, 2, "Error Sub-code: " |
| 1570 | | | "Unknown object's S-Num %u, C-Type %u", |
| 1571 | | | tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset + 1)); |
| 1572 | | | } else |
| 1573 | | | proto_tree_add_uint(cperror_tree, hf_cops_cperror_sub, tvb, offset, 2, cperror_sub); |
| 1574 | | | |
| 1575 | | | break; |
| 1576 | | | default: |
| 1577 | | | proto_tree_add_text(tree, tvb, offset, len, "Contents: %d bytes", len); |
| 1578 | | | break; |
| 1579 | | | } |
| 1580 | | | |
| 1581 | | | return 0; |
| 1582 | | | } |
| |