diff options
author | Yajun Zeng <beanz@marvell.com> | 2013-04-24 10:38:27 +0800 |
---|---|---|
committer | Yajun Zeng <beanz@marvell.com> | 2013-04-24 10:38:27 +0800 |
commit | be21e039d7d993872ac85a0279ea657e40f674fd (patch) | |
tree | 55c50288c294c2fa11c14b3c73ba17896f30147b | |
parent | 3030f344e77d14cf688c34f79c83a045c888825d (diff) |
Fix overflow of rand in ARTPConnection
without this fix, (rand()*1000)/RAND_MAX is mainly 0.
Change-Id: I48ae940a7b6974b197d81732774c9dcea107bcf1
Signed-off-by: Yajun Zeng <beanz@marvell.com>
-rw-r--r-- | media/libstagefright/rtsp/ARTPConnection.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp index 501a970b..af369b56 100644 --- a/media/libstagefright/rtsp/ARTPConnection.cpp +++ b/media/libstagefright/rtsp/ARTPConnection.cpp @@ -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) { |