[sr-dev] Random number generation

Hugh Waite hugh.waite at crocodile-rcs.com
Fri Apr 13 12:41:44 CEST 2012


Hello,
I have a question about random number generation within kamailio.

A number of modules use rand() to get a random value and in some places 
is re-seeding with srand(). I believe this is dangerous because rand() 
is used in the Via branch tag generator.
We have detected some real bugs (where srand is reseeding with 0 for 
every message, causing transaction mis-matching) but I'm not sure of the 
correct way to fix this (other than remove srand()).

Should all modules be using a 'core' random function (e.g. in srutils?) 
? And if so, is this library documented?

Regards,
Hugh

-- 
Hugh Waite
Senior Design Engineer
Crocodile RCS Ltd.




More information about the sr-dev mailing list