Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Computation  at packet-ppp.c:1636

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

decode_fcs

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ppp.c)expand/collapse
Show more  
 1511  tvbuff_t *
 1512  decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset)
 1513  {
 1514    tvbuff_t   *next_tvb;
 1515    gint       len, reported_len;
 1516    int        rx_fcs_offset;
 1517    guint32    rx_fcs_exp;
 1518    guint32    rx_fcs_got;
 1519   
 1520    /*
 1521     * Remove the FCS, if any, from the packet data.
 1522     */
 1523    switch (fcs_decode) {
 1524   
 1525    case NO_FCS:
 1526      next_tvb = tvb_new_subset(tvb, proto_offset, -1, -1);
 1527      break;
 1528   
 1529    case FCS_16:
 1530      /*
 1531       * Do we have the entire packet, and does it include a 2-byte FCS?
 1532       */
 1533      len = tvb_length_remaining(tvb, proto_offset);
 1534      reported_len = tvb_reported_length_remaining(tvb, proto_offset);
 1535      if (reported_len < 2 || len < 0) {
 1536        /*
 1537         * The packet is claimed not to even have enough data for a 2-byte FCS,
 1538         * or we're already past the end of the captured data.
 1539         * Don't slice anything off.
 1540         */
 1541        next_tvb = tvb_new_subset(tvb, proto_offset, -1, -1);
 1542      } else if (len < reported_len) {
 1543        /*
 1544         * The packet is claimed to have enough data for a 2-byte FCS, but 
 1545         * we didn't capture all of the packet.
 1546         * Slice off the 2-byte FCS from the reported length, and trim the 
 1547         * captured length so it's no more than the reported length; that 
 1548         * will slice off what of the FCS, if any, is in the captured
 1549         * length.
 1550         */
 1551        reported_len -= 2;
 1552        if (len > reported_len)
 1553          len = reported_len;
 1554        next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
 1555      } else {
 1556        /*
 1557         * We have the entire packet, and it includes a 2-byte FCS.
 1558         * Slice it off.
 1559         */
 1560        len -= 2;
 1561        reported_len -= 2;
 1562        next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
 1563   
 1564        /*
 1565         * Compute the FCS and put it into the tree.
 1566         */
 1567        rx_fcs_offset = proto_offset + len;
 1568        rx_fcs_exp = fcs16(tvb);
 1569        rx_fcs_got = tvb_get_letohs(tvb, rx_fcs_offset);
 1570        if (rx_fcs_got != rx_fcs_exp) {
 1571          proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 2,
 1572                              "FCS 16: 0x%04x [incorrect, should be 0x%04x]",
 1573                              rx_fcs_got, rx_fcs_exp);
 1574        } else {
 1575          proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 2,
 1576                              "FCS 16: 0x%04x [correct]",
 1577                              rx_fcs_got);
 1578        }
 1579      }
 1580      break;
 1581   
 1582    case FCS_32:
 1583      /*
 1584       * Do we have the entire packet, and does it include a 4-byte FCS?
 1585       */
 1586      len = tvb_length_remaining(tvb, proto_offset);
 1587      reported_len = tvb_reported_length_remaining(tvb, proto_offset);
 1588      if (reported_len < 4) {
 1589        /*
 1590         * The packet is claimed not to even have enough data for a 4-byte FCS.
 1591         * Just pass on the tvbuff as is.
 1592         */
 1593        next_tvb = tvb_new_subset(tvb, proto_offset, -1, -1);
 1594      } else if (len < reported_len) {
 1595        /*
 1596         * The packet is claimed to have enough data for a 4-byte FCS, but 
 1597         * we didn't capture all of the packet.
 1598         * Slice off the 4-byte FCS from the reported length, and trim the 
 1599         * captured length so it's no more than the reported length; that 
 1600         * will slice off what of the FCS, if any, is in the captured
 1601         * length.
 1602         */
 1603        reported_len -= 4;
 1604        if (len > reported_len)
 1605          len = reported_len;
 1606        next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
 1607      } else {
 1608        /*
 1609         * We have the entire packet, and it includes a 4-byte FCS.
 1610         * Slice it off.
 1611         */
 1612        len -= 4;
 1613        reported_len -= 4;
 1614        next_tvb = tvb_new_subset(tvb, proto_offset, len, reported_len);
 1615   
 1616        /*
 1617         * Compute the FCS and put it into the tree.
 1618         */
 1619        rx_fcs_offset = proto_offset + len;
 1620        rx_fcs_exp = fcs32(tvb);
 1621        rx_fcs_got = tvb_get_letohl(tvb, rx_fcs_offset);
 1622        if (rx_fcs_got != rx_fcs_exp) {
 1623          proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 4,
 1624                              "FCS 32: 0x%08x [incorrect, should be 0x%08x]",
 1625                              rx_fcs_got, rx_fcs_exp);
 1626        } else {
 1627          proto_tree_add_text(fh_tree, tvb, rx_fcs_offset, 4,
 1628                              "FCS 32: 0x%08x [correct]",
 1629                              rx_fcs_got);
 1630        }
 1631      }
 1632      break;
 1633   
 1634    default:
 1635     DISSECTOR_ASSERT_NOT_REACHED();
 1636     next_tvb = NULL;
 1637    }
 1638   
 1639    return next_tvb;
 1640  }
Show more  




Change Warning 1972.31527 : Unreachable Computation

Priority:
State:
Finding:
Owner:
Note: