summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/rtsp/ARTPConnection.cpp
diff options
context:
space:
mode:
authorYajun Zeng <beanz@marvell.com>2013-04-24 10:38:27 +0800
committerYajun Zeng <beanz@marvell.com>2013-04-24 10:38:27 +0800
commit6cb3f224d7e2280f8834d361bba1a72682aaaad1 (patch)
tree9c8911ba250bc2007b816e9d0831a9cf5390ea9d /media/libstagefright/rtsp/ARTPConnection.cpp
parent6db76e8b8f561355198fc91dd95498a59ad38a20 (diff)
downloadframeworks_av-6cb3f224d7e2280f8834d361bba1a72682aaaad1.zip
frameworks_av-6cb3f224d7e2280f8834d361bba1a72682aaaad1.tar.gz
frameworks_av-6cb3f224d7e2280f8834d361bba1a72682aaaad1.tar.bz2
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>
Diffstat (limited to 'media/libstagefright/rtsp/ARTPConnection.cpp')
-rw-r--r--media/libstagefright/rtsp/ARTPConnection.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp
index 501a970..af369b5 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) {