summaryrefslogtreecommitdiff
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorAndriy Gelman <andriy.gelman@gmail.com>2021-07-04 11:40:25 -0400
committerAndriy Gelman <andriy.gelman@gmail.com>2021-07-05 13:36:22 -0400
commit02387de90e71a6b035e3adf2446b6002ca135511 (patch)
tree7ae7248c089f5fd82bd51267f74090b4dc44b6b5 /libavformat/rtsp.c
parent78f21f4ec161b9eacb75823740eabd3b87b44efe (diff)
avformat/rtsp: Set port_off to zero for low min/max port range
Fixes: $ ffmpeg -min_port 32000 -max_port 32001 -i rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov -f null - [1] 303871 floating point exception (core dumped) Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d4ab8f28bf..f294d0ec24 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1438,7 +1438,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
int lower_transport, const char *real_challenge)
{
RTSPState *rt = s->priv_data;
- int rtx = 0, j, i, err, interleave = 0, port_off;
+ int rtx = 0, j, i, err, interleave = 0, port_off = 0;
RTSPStream *rtsp_st;
RTSPMessageHeader reply1, *reply = &reply1;
char cmd[MAX_URL_SIZE];
@@ -1457,9 +1457,11 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
/* Choose a random starting offset within the first half of the
* port range, to allow for a number of ports to try even if the offset
* happens to be at the end of the random range. */
+ if (rt->rtp_port_max - rt->rtp_port_min >= 4) {
port_off = av_get_random_seed() % ((rt->rtp_port_max - rt->rtp_port_min)/2);
/* even random offset */
port_off -= port_off & 0x01;
+ }
for (j = rt->rtp_port_min + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) {
char transport[MAX_URL_SIZE];