Skip to content

Commit

Permalink
Check of the last argument of the srtp_protect is int* or size_t*
Browse files Browse the repository at this point in the history
and use accordingly. They've changed that type recently causing
all tests to fail.
  • Loading branch information
sobomax committed Jan 12, 2024
1 parent 2dbc63b commit 37e78e1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
16 changes: 14 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,21 @@ fi
AC_CHECK_HEADER(srtp2/srtp.h, found_libsrtp2=yes)
if test "$found_libsrtp2" = yes
then
AC_CHECK_LIB(srtp2, srtp_init,
AC_CHECK_LIB(srtp2, srtp_init,[
LIBS_SRTP="-lsrtp2"
AC_DEFINE([ENABLE_SRTP2], 1, [Define if you have libsrtp2 library installed]))
# Test program to check if the srtp_protect function accepts size_t* argument
AC_MSG_CHECKING(['srtp_protect()' last argument type])
original_cflags="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <stdlib.h>
#include <srtp2/srtp.h>],
[srtp_t ctx; void* rtp_hdr; size_t len; return srtp_protect(ctx, rtp_hdr, &len);])],
[srtp_protect_lastarg=size_t], [srtp_protect_lastarg=int])
CFLAGS="$original_cflags"
AC_MSG_RESULT([$srtp_protect_lastarg])
AC_DEFINE_UNQUOTED([SRTP_PROTECT_LASTARG], [${srtp_protect_lastarg}], [Type of the last argument of the srtp_protect() API])
AC_DEFINE([ENABLE_SRTP2], 1, [Define if you have libsrtp2 library installed])])
else
# libsrtp
AC_CHECK_HEADER(srtp/srtp.h, found_libsrtp=yes)
Expand Down
7 changes: 6 additions & 1 deletion extractaudio/eaud_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ static int srtp_inited;
int
eaud_crypto_decrypt(struct eaud_crypto *crypto, uint8_t *pkt_raw, int pkt_len)
{
int status, octets_recvd;
int status;
#if defined(SRTP_PROTECT_LASTARG)
SRTP_PROTECT_LASTARG octets_recvd;
#else
size_t octets_recvd;
#endif
rtp_hdr_t *rpkt;

if (srtp_inited == 0) {
Expand Down
14 changes: 12 additions & 2 deletions modules/dtls_gw/rtpp_dtls_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,12 @@ rtpp_dtls_conn_dtls_recv(struct rtpp_dtls_conn *self,
static int
rtpp_dtls_conn_rtp_send(struct rtpp_dtls_conn *self, struct pkt_proc_ctx *pktxp)
{
int status, len;
int status;
#if defined(SRTP_PROTECT_LASTARG)
SRTP_PROTECT_LASTARG len;
#else
size_t len;
#endif
struct rtpp_dtls_conn_priv *pvt;

PUB2PVT(self, pvt);
Expand All @@ -477,7 +482,12 @@ rtpp_dtls_conn_rtp_send(struct rtpp_dtls_conn *self, struct pkt_proc_ctx *pktxp)
static int
rtpp_dtls_conn_srtp_recv(struct rtpp_dtls_conn *self, struct pkt_proc_ctx *pktxp)
{
int status, len;
int status;
#if defined(SRTP_PROTECT_LASTARG)
SRTP_PROTECT_LASTARG len;
#else
size_t len;
#endif
struct rtpp_dtls_conn_priv *pvt;

PUB2PVT(self, pvt);
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@
/* The number of bytes in type time_t */
#undef SIZEOF_TIME_T

/* Type of the last argument of the srtp_protect() API */
#undef SRTP_PROTECT_LASTARG

/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
Expand Down

0 comments on commit 37e78e1

Please sign in to comment.