Commit b7fed2c0 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fix for bb10 compil

parent 4214b357
......@@ -856,18 +856,27 @@ static int ortp_wincrypto_random(unsigned int *rand_number){
}
#endif
static unsigned int ortp_urandom(void) {
static int fd=-1;
if (fd==-1) fd=open("/dev/urandom",O_RDONLY);
if (fd!=-1){
unsigned int tmp;
if (read(fd,&tmp,4)!=4){
ortp_error("Reading /dev/urandom failed.");
}else return tmp;
} else ortp_error("Could not open /dev/urandom");
return (unsigned int) random();
}
unsigned int ortp_random(void){
#ifdef HAVE_ARC4RANDOM
#if defined(__QNXNTO__) // There is a false positive with blackberry build
return ortp_urandom();
#else
return arc4random();
#endif
#elif defined(__linux) || defined(__APPLE__)
static int fd=-1;
if (fd==-1) fd=open("/dev/urandom",O_RDONLY);
if (fd!=-1){
unsigned int tmp;
if (read(fd,&tmp,4)!=4){
ortp_error("Reading /dev/urandom failed.");
}else return tmp;
}else ortp_error("Could not open /dev/urandom");
return ortp_urandom();
#elif defined(_WIN32)
static int initd=0;
unsigned int ret;
......@@ -891,10 +900,6 @@ unsigned int ortp_random(void){
ortp_warning("ortp: Random generator is using rand(), this is unsecure !");
}
return rand()<<16 | rand();
#endif
/*fallback to UNIX random()*/
#ifndef _WIN32
return (unsigned int) random();
#endif
}
bool_t ortp_is_multicast_addr(const struct sockaddr *addr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment