Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at tcap-persistentdata.c:1710

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

tcaphash_ansi_matching

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/tcap-persistentdata.c)expand/collapse
Show more  
 1487  static struct tcaphash_context_t *
 1488  tcaphash_ansi_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 1489                         struct tcapsrt_info_t *p_tcapsrt_info)
 1490  {
 1491    struct tcaphash_context_t *p_tcaphash_context=NULL;
 1492    struct tcaphash_context_key_t tcaphash_context_key;
 1493    struct tcaphash_ansicall_t *p_tcaphash_ansicall, *p_new_tcaphash_ansicall;
 1494    struct tcaphash_ansi_info_key_t tcaphash_ansi_key;
 1495    proto_item *pi;
 1496    nstime_t delta;
 1497    gboolean isResponse=FALSE;
 1498    proto_tree * stat_tree=NULL;
 1499    proto_item * stat_item=NULL;
 1500   
 1501    /* prepare the key data */
 1502    tcaphash_ansi_key.tid = p_tcapsrt_info->src_tid;
 1503    if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
 1504    {
 1505      /* We have MTP3 PCs (so we can safely do this cast) */
 1506      tcaphash_ansi_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
 1507      tcaphash_ansi_key.dpc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data);
 1508    } else {
 1509      /* Don't have MTP3 PCs (maybe we're over SUA?) */
 1510      tcaphash_ansi_key.opc_hash = g_str_hash(address_to_str(&pinfo->src));
 1511      tcaphash_ansi_key.dpc_hash = g_str_hash(address_to_str(&pinfo->dst));
 1512    }
 1513    tcaphash_ansi_key.hashKey=tcaphash_ansi_calchash(&tcaphash_ansi_key);
 1514   
 1515    /* look up the request */
 1516  #ifdef DEBUG_TCAPSRT 
 1517    dbg(10,"\n Hansi #%u ", pinfo->fd->num);
 1518    dbg(11,"key %lx ",tcaphash_ansi_key.hashKey);
 1519    dbg(51,"PC %s %s ",address_to_str(&pinfo->src), address_to_str(&pinfo->dst));
 1520    dbg(51,"Tid %lx ",tcaphash_ansi_key.tid);
 1521  #endif
 1522    p_tcaphash_ansicall = (struct tcaphash_ansicall_t *)
 1523      g_hash_table_lookup(tcaphash_ansi, &tcaphash_ansi_key);
 1524   
 1525    if (p_tcaphash_ansicall) {
 1526      /* Walk through list of transaction with identical keys */
 1527      do {
 1528        /* Check if the request with this reqSeqNum has been seen */
 1529        if (pinfo->fd->num == p_tcaphash_ansicall->context->first_frame) {
 1530          /* We have seen this request before -> do nothing */
 1531  #ifdef DEBUG_TCAPSRT 
 1532          dbg(22,"Request already seen ");
 1533  #endif
 1534          isResponse=FALSE;
 1535          p_tcaphash_context=p_tcaphash_ansicall->context;
 1536          break;
 1537        }
 1538   
 1539        /* Check if the reponse with this reqSeqNum has been seen */
 1540        if (pinfo->fd->num == p_tcaphash_ansicall->context->last_frame) {
 1541          /* We have seen this response before -> do nothing */
 1542  #ifdef DEBUG_TCAPSRT 
 1543          dbg(22,"Response already seen ");
 1544  #endif
 1545          isResponse=TRUE;
 1546          p_tcaphash_context=p_tcaphash_ansicall->context;
 1547          break;
 1548        }
 1549   
 1550        /* Check for the first Request without Response 
 1551         received before this frame */
 1552        if ( pinfo->fd->num > p_tcaphash_ansicall->context->first_frame &&
 1553             p_tcaphash_ansicall->context->last_frame==0 ) {
 1554          /* Take it, and update the context */
 1555   
 1556  #ifdef DEBUG_TCAPSRT 
 1557          dbg(12,"Update key %lx ",tcaphash_ansi_key.hashKey);
 1558  #endif
 1559          p_tcaphash_ansicall->context->last_frame = pinfo->fd->num;
 1560          p_tcaphash_ansicall->context->responded = TRUE;
 1561          p_tcaphash_ansicall->context->closed = TRUE;
 1562          p_tcaphash_context=p_tcaphash_ansicall->context;
 1563          isResponse=TRUE;
 1564   
 1565          if (gtcap_DisplaySRT && tree) {
 1566            stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat");
 1567            PROTO_ITEM_SET_GENERATED(stat_item);
 1568            stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat);
 1569   
 1570            pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id);
 1571            PROTO_ITEM_SET_GENERATED(pi);
 1572   
 1573  #ifdef DEBUG_TCAPSRT 
 1574            dbg(20,"Display framereqlink %d ",p_tcaphash_context->first_frame);
 1575  #endif
 1576            /* Indicate the frame to which this is a reply. */
 1577            pi = proto_tree_add_uint_format(stat_tree, hf_tcapsrt_EndSession, tvb, 0, 0,
 1578                                            p_tcaphash_context->first_frame,
 1579                                            "Begin of session in frame %u",
 1580                                            p_tcaphash_context->first_frame);
 1581            PROTO_ITEM_SET_GENERATED(pi);
 1582            /* Calculate Service Response Time */
 1583            nstime_delta(&delta, &pinfo->fd->abs_ts, &p_tcaphash_context->begin_time);
 1584   
 1585            /* display Service Response Time and make it filterable */
 1586            pi = proto_tree_add_time(stat_tree, hf_tcapsrt_SessionTime, tvb, 0, 0, &delta);
 1587            PROTO_ITEM_SET_GENERATED(pi);
 1588          }
 1589          break;
 1590        } /* Lastframe=0, so take it */
 1591   
 1592   
 1593        /* If the last record for Tcap transaction with identifier has been reached */
 1594        if (!p_tcaphash_ansicall->next_ansicall) {
 1595          /* check if we have to create a new record or not */
 1596          /* if last request has been responded (response number in known)
 1597             and this request appears after last response (has bigger frame number)
 1598             and last request occured after the timeout for repetition,
 1599             or
 1600             if last request hasn't been responded (so number unknown)
 1601             and this request appears after last request (has bigger frame number)
 1602             and this request occured after the timeout for message lost */
 1603          if ( ( p_tcaphash_ansicall->context->last_frame != 0 
 1604                 && pinfo->fd->num > p_tcaphash_ansicall->context->first_frame
 1605                 && (guint) pinfo->fd->abs_ts.secs > (guint)(p_tcaphash_ansicall->context->begin_time.secs + gtcap_RepetitionTimeout)
 1606                 ) ||
 1607               ( p_tcaphash_ansicall->context->last_frame == 0 
 1608                 && pinfo->fd->num > p_tcaphash_ansicall->context->first_frame
 1609                 && (guint)pinfo->fd->abs_ts.secs > (guint)(p_tcaphash_ansicall->context->begin_time.secs + gtcap_LostTimeout)
 1610                 )
 1611               )
 1612            {
 1613              /* we decide that we have a new request */
 1614              /* Append new record to the list */
 1615  #ifdef DEBUG_TCAPSRT 
 1616              dbg(12,"(timeout) Append key %lx ",tcaphash_ansi_key.hashKey);
 1617              dbg(12,"Frame %u rsp %u ",pinfo->fd->num,p_tcaphash_ansicall->context->last_frame );
 1618  #endif
 1619              tcaphash_context_key.session_id = tcapsrt_global_SessionId++;
 1620              p_tcaphash_context = new_tcaphash_context(&tcaphash_context_key, pinfo);
 1621              p_new_tcaphash_ansicall = append_tcaphash_ansicall(p_tcaphash_ansicall,
 1622                                                                   p_tcaphash_context,
 1623                                                                   pinfo);
 1624   
 1625  #ifdef DEBUG_TCAPSRT 
 1626              dbg(12,"Update key %lx ",tcaphash_ansi_key.hashKey);
 1627  #endif
 1628              update_tcaphash_ansicall(p_new_tcaphash_ansicall, pinfo);
 1629              p_tcaphash_ansicall=p_new_tcaphash_ansicall;
 1630            } else {
 1631   
 1632            /* If the Tid is reused for a closed Transaction */
 1633            if ( p_tcaphash_ansicall->context->closed) {
 1634  #ifdef DEBUG_TCAPSRT 
 1635              dbg(12,"(closed) Append key %lu ",tcaphash_ansi_key.hashKey);
 1636              dbg(12,"Frame %u rsp %u ",pinfo->fd->num,p_tcaphash_ansicall->context->last_frame );
 1637  #endif
 1638              tcaphash_context_key.session_id = tcapsrt_global_SessionId++;
 1639              p_tcaphash_context = new_tcaphash_context(&tcaphash_context_key, pinfo);
 1640              p_new_tcaphash_ansicall = append_tcaphash_ansicall(p_tcaphash_ansicall,
 1641                                                                   p_tcaphash_context,
 1642                                                                   pinfo);
 1643   
 1644  #ifdef DEBUG_TCAPSRT 
 1645              dbg(12,"Update key %lu ",tcaphash_ansi_key.hashKey);
 1646  #endif
 1647              update_tcaphash_ansicall(p_new_tcaphash_ansicall, pinfo);
 1648              p_tcaphash_ansicall=p_new_tcaphash_ansicall;
 1649   
 1650            } else {
 1651              /* the Tid is reused for an opened Transaction */
 1652              /* so, this is the reply to the request of our context */
 1653              p_tcaphash_context=p_tcaphash_ansicall->context;
 1654  #ifdef DEBUG_TCAPSRT 
 1655              dbg(12,"Found, req=%d ",p_tcaphash_context->first_frame);
 1656  #endif
 1657   
 1658              if (gtcap_DisplaySRT && tree) {
 1659                stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat");
 1660                PROTO_ITEM_SET_GENERATED(stat_item);
 1661                stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat);
 1662   
 1663                pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id);
 1664                PROTO_ITEM_SET_GENERATED(pi);
 1665   
 1666  #ifdef DEBUG_TCAPSRT 
 1667                dbg(20,"Display framereqlink %d ",p_tcaphash_context->first_frame);
 1668  #endif
 1669                /* Indicate the frame to which this is a reply. */
 1670                pi = proto_tree_add_uint_format(stat_tree, hf_tcapsrt_EndSession, tvb, 0, 0,
 1671                                                p_tcaphash_context->first_frame,
 1672                                                "Begin of session in frame %u",
 1673                                                p_tcaphash_context->first_frame);
 1674                PROTO_ITEM_SET_GENERATED(pi);
 1675                /* Calculate Service Response Time */
 1676                nstime_delta(&delta, &pinfo->fd->abs_ts, &p_tcaphash_context->begin_time);
 1677   
 1678                /* display Service Response Time and make it filterable */
 1679                pi = proto_tree_add_time(stat_tree, hf_tcapsrt_SessionTime, tvb, 0, 0, &delta);
 1680                PROTO_ITEM_SET_GENERATED(pi);
 1681              }
 1682              p_tcaphash_context=p_tcaphash_ansicall->context;
 1683            } /* test with Timeout */
 1684          } /* closed */
 1685          break;
 1686        } /* Next call is NULL */
 1687        p_tcaphash_ansicall = p_tcaphash_ansicall->next_ansicall;
 1688      } while (p_tcaphash_ansicall != NULL );
 1689      /*
 1690       * New TCAP context 
 1691       */
 1692    } else { /* p_tcaphash_ansicall has not been found */
 1693  #ifdef DEBUG_TCAPSRT 
 1694      dbg(10,"New key %lx ",tcaphash_ansi_key.hashKey);
 1695  #endif
 1696   
 1697      tcaphash_context_key.session_id = tcapsrt_global_SessionId++;
 1698      p_tcaphash_context = new_tcaphash_context(&tcaphash_context_key, pinfo);
 1699      p_tcaphash_ansicall = new_tcaphash_ansi(&tcaphash_ansi_key, p_tcaphash_context);
 1700   
 1701  #ifdef DEBUG_TCAPSRT 
 1702      dbg(11,"Update key %lx ",tcaphash_ansi_key.hashKey);
 1703      dbg(11,"Frame reqlink #%u ", pinfo->fd->num);
 1704  #endif
 1705      update_tcaphash_ansicall(p_tcaphash_ansicall, pinfo);
 1706    }
 1707   
 1708    /* display tcap session, if available */
 1709    if ( gtcap_DisplaySRT && tree &&
 1710         p_tcaphash_context &&
 1711         p_tcaphash_context->session_id) {
 1712      stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat");
 1713      PROTO_ITEM_SET_GENERATED(stat_item);
 1714      stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat);
 1715      pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id);
 1716      PROTO_ITEM_SET_GENERATED(pi);
 1717    }
 1718   
 1719   
 1720    /* add link to response frame, if available */
 1721    if( gtcap_DisplaySRT && stat_tree &&
 1722        p_tcaphash_ansicall->context->last_frame != 0){
 1723      if (!isResponse) { /* Request */
 1724  #ifdef DEBUG_TCAPSRT 
 1725        dbg(20,"Display_frameRsplink %d ",p_tcaphash_ansicall->context->last_frame);
 1726  #endif
 1727        pi = proto_tree_add_uint_format(stat_tree, hf_tcapsrt_BeginSession, tvb, 0, 0,
 1728                                        p_tcaphash_ansicall->context->last_frame,
 1729                                        "End of session in frame %u",
 1730                                        p_tcaphash_ansicall->context->last_frame);
 1731        PROTO_ITEM_SET_GENERATED(pi);
 1732      } else { /* Response */
 1733  #ifdef DEBUG_TCAPSRT 
 1734        dbg(20,"Display framereqlink %d ",p_tcaphash_context->first_frame);
 1735  #endif
 1736        /* Indicate the frame to which this is a reply. */
 1737        if (gtcap_DisplaySRT) {
 1738          pi = proto_tree_add_uint_format(stat_tree, hf_tcapsrt_EndSession, tvb, 0, 0,
 1739                                          p_tcaphash_context->first_frame,
 1740                                          "Begin of session in frame %u",
 1741                                          p_tcaphash_context->first_frame);
 1742          PROTO_ITEM_SET_GENERATED(pi);
 1743          /* Calculate Service Response Time */
 1744          nstime_delta(&delta, &pinfo->fd->abs_ts, &p_tcaphash_context->begin_time);
 1745   
 1746          /* display Service Response Time and make it filterable */
 1747          pi = proto_tree_add_time(stat_tree, hf_tcapsrt_SessionTime, tvb, 0, 0, &delta);
 1748          PROTO_ITEM_SET_GENERATED(pi);
 1749        }
 1750      } /* Request or Response */
 1751    }
 1752    return p_tcaphash_context;
 1753  }
Show more  




Change Warning 12322.31062 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: