From patchwork Sun Apr 4 15:36:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andriy Gelman X-Patchwork-Id: 26737 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 56CC044B6C8 for ; Sun, 4 Apr 2021 18:44:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38654687F1A; Sun, 4 Apr 2021 18:44:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 707CA6807B5 for ; Sun, 4 Apr 2021 18:44:09 +0300 (EEST) Received: by mail-qt1-f178.google.com with SMTP id c6so6967625qtc.1 for ; Sun, 04 Apr 2021 08:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yUz76R7DAX0fsaxPNrgBcmhywihWz+pJR1FZj9nYjZo=; b=C1H+VkxXD3M22XNHw4qKLc9TcByDph+kXhOjsAxE6Ol8k3jzYDWxpmcOiCE96l0BSe mNoED7jwvr+uGpa1umFtzlXLA6BVcus8eEG+gaGWP65DqaA+t3LiQKjrLpAd2G/Mxdmj KrQUHoAG0cL9TcyUIQLsOU1RNdXnAcxNgHxI0M4gYmbXHLiVRaCuzLudDg9a6Qploz7r n4Vf4OKswkbEs7ehmI5V/4gCpxwGIRSsuWdwCe+iODpnl7FfXTpcoTUK6+EVS/488cyV hPD9CSCgpedTeWyguZCjbF83t2x5aoigOIg3AvQRk3myVEHAAqVKF468t17YdFfUlNCQ 5XnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yUz76R7DAX0fsaxPNrgBcmhywihWz+pJR1FZj9nYjZo=; b=BLQcIPZnjd0HQwdOnT6qvuf3blHcnz9DBBT+jGwNP79SMvEFBQGPBGw0KoGmoI4kcp YTQCqn/LhW5nLxRqCASknV9m33KN50QId5qUz58E4kJoN3HVEIC3JlZ2e4ermKZzW78L OwqMdlFnMMl3ldLC+69VzsCRx8rtpPrFhnCsT7RoAzAvKdKLhoIEea3ShsAKaUnNRo+f anVgsd8Dbhxe4vucvGx4EjIR+b7UVXWXkHvPI/8ek8QLohaIR26B9l8z0XuYrQ+cU+Uz pgKpHRX0RTAC3CnQdZK+gkrm4JHjHJ2qhmhBDBIsH14q/p4yy1SBqunuQZdEAuYlrXU5 QhUQ== X-Gm-Message-State: AOAM533L1WN6XvKLFHMAXKY6fdGpiZtEsviF/AM887L9xkHc14ldd27+ YeaQXLcXv5jtCRIAPK5Hq/un23STCUk= X-Google-Smtp-Source: ABdhPJztJX5CqF/avjJD5TbW3epfR1nCHhk2x7wMPyBkQl61/kJKNx7ZDUu8yp0xxZe/JOe52mEXeQ== X-Received: by 2002:a05:622a:191:: with SMTP id s17mr6026740qtw.33.1617550618178; Sun, 04 Apr 2021 08:36:58 -0700 (PDT) Received: from localhost.localdomain (c-73-149-98-40.hsd1.ma.comcast.net. [73.149.98.40]) by smtp.gmail.com with ESMTPSA id m13sm11294372qkk.16.2021.04.04.08.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Apr 2021 08:36:57 -0700 (PDT) From: Andriy Gelman X-Google-Original-From: Andriy Gelman To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Apr 2021 11:36:43 -0400 Message-Id: <20210404153645.565251-1-andriy.gelman@gmail.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/rtsp: Fix floating point exception for low min/max port range X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andriy Gelman Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Andriy Gelman 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 --- 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];