Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-cops.c:1402

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

dissect_cops_pr_object_data

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-cops.c)expand/collapse
Show more  
 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) /* Not Prefix Provisioning Instance Identifier (PPRID) */
 1397                            break;
 1398                    /* Never tested this branch */
 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);
 1403   
 1404                    if (oid_tvb) {
 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; /* Not Provisioning Instance Identifier (PRID) */
 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                    /* TODO: check pc, class and tag */
 1433   
 1434                    encoid = ep_tvb_memdup(tvb,offset,encoid_len);
 1435   
 1436                    if (*pprid_subids) {
 1437                            /* Never tested this branch */
 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                       TODO: from RFC 3159 find-out how the values are mapped,
 1450                             when instead of an oid for an xxEntry 
 1451                             we have one decribing a scalar or something else,
 1452                             what's bellow works in most cases but is not complete.
 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;/* Not Encoded Provisioning Instance Data (EPD) */
 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                     * XXX: LAZYNESS WARNING:
 1473                     * We are assuming that for the first element in the sequence 
 1474                     * that describes an entry subid==1, and, that the subsequent elements
 1475                     * use ++subid; This is true for all IETF's PIBs (and good sense
 1476                     * indicates it should be this way) but AFAIK there's nothing in
 1477                     * SMIv2 that imposes this restriction.  -- a lazy lego 
 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                                     * XXX: LAZYNESS WARNING:
 1504                                     * We are assuming that the value of the sequenced item is of
 1505                                     * the right class, the right type and the right legth.
 1506                                     * We should check that to avoid throwing a Malformed packet and 
 1507                                     * keep dissecting.
 1508                                     * We should verify the class and the tag match what we expect as well,
 1509                                     * but COPS and SNMP use different tags (&#@$!) so the typedata in oid_info_t 
 1510                                     * does not work here.
 1511                                     * -- a lazy lego 
 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; /*Not  Error Provisioning Instance Identifier (ErrorPRID)*/
 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) /* Not Global Provisioning Error Object (GPERR) */
 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) /*Not PRC Class Provisioning Error Object (CPERR) */
 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  }
Show more  




Change Warning 12508.35614 : Ignored Return Value

Because they are very similar, this warning shares annotations with warning 12508.35615.

Priority:
State:
Finding:
Owner:
Note: