- Timestamp:
- Apr 25, 2017 2:13:56 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
r5586 r5588 1618 1618 1619 1619 1620 static pj_status_t fill_local_crypto(pj_pool_t *pool, 1621 const pjmedia_sdp_media *m_loc, 1622 pjmedia_srtp_crypto loc_crypto[], 1623 int *count) 1624 { 1625 int i; 1626 int crypto_count = 0; 1627 pj_status_t status = PJ_SUCCESS; 1628 1629 for (i = 0; i < *count; ++i) { 1630 pj_bzero(&loc_crypto[i], sizeof(loc_crypto[i])); 1631 } 1632 1633 for (i = 0; i < (int)m_loc->attr_count; ++i) { 1634 pjmedia_srtp_crypto tmp_crypto; 1635 int loc_tag; 1636 1637 if (pj_stricmp(&m_loc->attr[i]->name, &ID_CRYPTO) != 0) 1638 continue; 1639 1640 status = parse_attr_crypto(pool, m_loc->attr[i], 1641 &tmp_crypto, &loc_tag); 1642 if (status != PJ_SUCCESS) 1643 return status; 1644 1645 if (loc_tag > *count) 1646 return PJMEDIA_SRTP_ESDPINCRYPTOTAG; 1647 1648 loc_crypto[loc_tag-1] = tmp_crypto; 1649 ++crypto_count; 1650 } 1651 *count = crypto_count; 1652 return status; 1653 } 1654 1620 1655 1621 1656 static pj_status_t transport_media_start(pjmedia_transport *tp, … … 1629 1664 pj_status_t status; 1630 1665 unsigned i; 1666 pjmedia_srtp_crypto loc_crypto[PJMEDIA_SRTP_MAX_CRYPTOS]; 1667 int loc_cryto_cnt = PJMEDIA_SRTP_MAX_CRYPTOS; 1631 1668 1632 1669 PJ_ASSERT_RETURN(tp && pool && sdp_local && sdp_remote, PJ_EINVAL); … … 1661 1698 //return PJMEDIA_SDP_EINPROTO; 1662 1699 //} 1700 fill_local_crypto(srtp->pool, m_loc, loc_crypto, &loc_cryto_cnt); 1663 1701 } else if (srtp->setting.use == PJMEDIA_SRTP_MANDATORY) { 1664 1702 if (pj_stricmp(&m_rem->desc.transport, &ID_RTP_SAVP)) { … … 1666 1704 return PJMEDIA_SDP_EINPROTO; 1667 1705 } 1706 fill_local_crypto(srtp->pool, m_loc, loc_crypto, &loc_cryto_cnt); 1668 1707 } 1669 1708 } … … 1674 1713 pj_bool_t has_crypto_attr = PJ_FALSE; 1675 1714 int rem_tag; 1715 int j; 1676 1716 1677 1717 for (i=0; i<m_rem->attr_count; ++i) { … … 1693 1733 1694 1734 1695 /* our offer tag is always ordered by setting */ 1696 if (rem_tag < 1 || rem_tag > (int)srtp->setting.crypto_count) { 1735 /* Tag range check, our tags in the offer must be in the SRTP 1736 * setting range, so does the remote answer's. The remote answer's 1737 * tag must not exceed the tag range of the local offer. 1738 */ 1739 if (rem_tag < 1 || rem_tag > (int)srtp->setting.crypto_count || 1740 rem_tag > loc_cryto_cnt) 1741 1742 { 1697 1743 DEACTIVATE_MEDIA(pool, m_loc); 1698 1744 return PJMEDIA_SRTP_ESDPINCRYPTOTAG; … … 1700 1746 1701 1747 /* match the crypto name */ 1702 if (pj_stricmp(&tmp_tx_crypto.name, 1703 &srtp->setting.crypto[rem_tag-1].name) != 0)1748 if (pj_stricmp(&tmp_tx_crypto.name, 1749 &loc_crypto[rem_tag-1].name) != 0) 1704 1750 { 1705 1751 DEACTIVATE_MEDIA(pool, m_loc); … … 1707 1753 } 1708 1754 1709 srtp->tx_policy_neg = srtp->setting.crypto[rem_tag-1]; 1755 /* Find the crypto from the setting. */ 1756 for (j = 0; j < (int)srtp->setting.crypto_count; ++j) { 1757 if (pj_stricmp(&tmp_tx_crypto.name, 1758 &srtp->setting.crypto[j].name) == 0) 1759 1760 { 1761 srtp->tx_policy_neg = srtp->setting.crypto[j]; 1762 break; 1763 } 1764 } 1765 1710 1766 srtp->rx_policy_neg = tmp_tx_crypto; 1711 1767 }
Note: See TracChangeset
for help on using the changeset viewer.