Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 189660fd authored by Andreas Huber's avatar Andreas Huber Committed by Gerrit Code Review
Browse files

Merge "Fix overflow of rand in ARTPConnection"

parents aa47eb2e 6cb3f224
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -117,7 +117,8 @@ void ARTPConnection::MakePortPair(

    bumpSocketBufferSize(*rtcpSocket);

    unsigned start = (rand() * 1000)/ RAND_MAX + 15550;
    /* rand() * 1000 may overflow int type, use long long */
    unsigned start = (unsigned)((rand()* 1000ll)/RAND_MAX) + 15550;
    start &= ~1;

    for (unsigned port = start; port < 65536; port += 2) {