Module: kamailio Branch: 5.8 Commit: 9c74ec421f7d81dc901ed2c71b844c8bb595321d URL: https://github.com/kamailio/kamailio/commit/9c74ec421f7d81dc901ed2c71b844c8b...
Author: Henning Westerholt hw@gilawa.com Committer: Xenofon Karamanos 22965395+xkaraman@users.noreply.github.com Date: 2025-06-26T10:53:50Z
rtpproxy: improve randomness of cookie by using PNRG and random sequence numbers
(cherry picked from commit 04686c40d380e16e55c359cbc6bfc28f644a4c0b)
---
Modified: src/modules/rtpproxy/rtpproxy.c
---
Diff: https://github.com/kamailio/kamailio/commit/9c74ec421f7d81dc901ed2c71b844c8b... Patch: https://github.com/kamailio/kamailio/commit/9c74ec421f7d81dc901ed2c71b844c8b...
---
diff --git a/src/modules/rtpproxy/rtpproxy.c b/src/modules/rtpproxy/rtpproxy.c index f6ea6b1b12d..610c7034eb7 100644 --- a/src/modules/rtpproxy/rtpproxy.c +++ b/src/modules/rtpproxy/rtpproxy.c @@ -74,6 +74,7 @@ #include "../../core/dset.h" #include "../../core/route.h" #include "../../core/kemi.h" +#include "../../core/rand/fastrand.h" #include "../../modules/tm/tm_load.h" #include "rtpproxy.h" #include "rtpproxy_funcs.h" @@ -150,7 +151,6 @@ static int pv_get_rtppstat_f(struct sip_msg *, pv_param_t *, pv_value_t *); static int rtpproxy_disable_tout = 60; static int rtpproxy_retr = 5; static int rtpproxy_tout = 1; -static pid_t mypid; static unsigned int myseqn = 0; static str nortpproxy_str = str_init("a=nortpproxy:yes"); static str extra_id_pv_param = {NULL, 0}; @@ -782,9 +782,10 @@ static int child_init(int rank) return 0; }
- /* Iterate known RTP proxies - create sockets */ - mypid = getpid(); + /* random start value for for cookie sequence number */ + myseqn = fastrand();
+ /* Iterate known RTP proxies - create sockets */ rtpp_socks = (int *)pkg_malloc(sizeof(int) * rtpp_no); if(rtpp_socks == NULL) { LM_ERR("no more pkg memory\n"); @@ -1200,7 +1201,7 @@ static char *gencookie(void) { static char cook[34];
- sprintf(cook, "%d_%u ", (int)mypid, myseqn); + sprintf(cook, "%u_%u ", fastrand(), myseqn); myseqn++; return cook; }