Skip to content

Commit

Permalink
common: Fix crash with RCE_SRTP without Crypto++
Browse files Browse the repository at this point in the history
  • Loading branch information
jrsnen committed Jul 25, 2024
1 parent 60cc41d commit 6b91e18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
13 changes: 7 additions & 6 deletions src/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@ uvgrtp::media_stream* uvgrtp::session::create_stream(uint16_t src_port, uint16_t
rtp_errno = RTP_INVALID_VALUE;
return nullptr;
}

if (rce_flags & RCE_SRTP && !uvgrtp::crypto::enabled())
{
UVG_LOG_ERROR("RCE_SRTP requires inclusion of Crypto++ during compilation!");
rtp_errno = RTP_GENERIC_ERROR;
return nullptr;
}

uvgrtp::media_stream* stream =
new uvgrtp::media_stream(cname_, remote_address_, local_address_, src_port, dst_port, fmt, sf_, rce_flags);

if (rce_flags & RCE_SRTP) {
if (!uvgrtp::crypto::enabled()) {
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
delete stream;
rtp_errno = RTP_GENERIC_ERROR;
return nullptr;
}

session_mtx_.lock();
if (!zrtp_) {
Expand Down
14 changes: 0 additions & 14 deletions test/test_5_srtp_zrtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ void test_user_key(Key_length len)
std::cout << "Starting ZRTP sender thread" << std::endl;
uvgrtp::context ctx;

if (!ctx.crypto_enabled())
{
std::cout << "Please link crypto to uvgRTP library in order to tests its SRTP user keys!" << std::endl;
FAIL();
return;
}

uint8_t *key = new uint8_t[len];
uint8_t salt[SALT_SIZE_BYTES] = { 0 };

Expand Down Expand Up @@ -188,13 +181,6 @@ TEST(EncryptionTests, zrtp)
{
uvgrtp::context ctx;

if (!ctx.crypto_enabled())
{
std::cout << "Please link crypto to uvgRTP library in order to tests its ZRTP feature!" << std::endl;
FAIL();
return;
}

uvgrtp::session* sender_session = ctx.create_session(RECEIVER_ADDRESS, SENDER_ADDRESS);
uvgrtp::session* receiver_session = ctx.create_session(SENDER_ADDRESS, RECEIVER_ADDRESS);

Expand Down

0 comments on commit 6b91e18

Please sign in to comment.