Message ID | 20210404153645.565251-1-andriy.gelman@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel,1/3] avformat/rtsp: Fix floating point exception for low min/max port range | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
On Sun, 04. Apr 11:36, Andriy Gelman wrote: > From: Andriy Gelman <andriy.gelman@gmail.com> > > Fixed by setting port offset to zero when it cannot be computed. > > To reproduce: > $ 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) > > Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> > --- > libavformat/rtsp.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > index 25bdf475b3..76efbf42cd 100644 > --- a/libavformat/rtsp.c > +++ b/libavformat/rtsp.c > @@ -1446,7 +1446,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]; > @@ -1465,9 +1465,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 > 1) { > 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]; > -- > 2.31.0 > ping for the set
> On Apr 4, 2021, at 11:36 PM, Andriy Gelman <andriy.gelman@gmail.com> wrote: > > From: Andriy Gelman <andriy.gelman@gmail.com> > > Fixed by setting port offset to zero when it cannot be computed. > > To reproduce: > $ 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) > > Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> > --- > libavformat/rtsp.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > index 25bdf475b3..76efbf42cd 100644 > --- a/libavformat/rtsp.c > +++ b/libavformat/rtsp.c > @@ -1446,7 +1446,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]; > @@ -1465,9 +1465,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 > 1) { > port_off = av_get_random_seed() % ((rt->rtp_port_max - rt->rtp_port_min)/2); > /* even random offset */ > port_off -= port_off & 0x01; > + } (rt->rtp_port_max - rt->rtp_port_min)/2 should larger than one, otherwise port_off is always zero. So how about `if (rt->rtp_port_max - rt->rtp_port_min >= 4)`? > > for (j = rt->rtp_port_min + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) { > char transport[MAX_URL_SIZE]; > -- > 2.31.0 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Hi Zhili, On Sun, 04. Jul 19:00, "zhilizhao(赵志立)" wrote: > > > > On Apr 4, 2021, at 11:36 PM, Andriy Gelman <andriy.gelman@gmail.com> wrote: > > > > From: Andriy Gelman <andriy.gelman@gmail.com> > > > > Fixed by setting port offset to zero when it cannot be computed. > > > > To reproduce: > > $ 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) > > > > Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> > > --- > > libavformat/rtsp.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > > index 25bdf475b3..76efbf42cd 100644 > > --- a/libavformat/rtsp.c > > +++ b/libavformat/rtsp.c > > @@ -1446,7 +1446,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]; > > @@ -1465,9 +1465,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 > 1) { > > port_off = av_get_random_seed() % ((rt->rtp_port_max - rt->rtp_port_min)/2); > > /* even random offset */ > > port_off -= port_off & 0x01; > > + } > > (rt->rtp_port_max - rt->rtp_port_min)/2 should larger than one, otherwise port_off is always zero. > > So how about `if (rt->rtp_port_max - rt->rtp_port_min >= 4)`? > Sure, this way works too. I don't mind either way. Thanks,
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 25bdf475b3..76efbf42cd 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1446,7 +1446,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]; @@ -1465,9 +1465,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 > 1) { 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];