From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4CE9AA04A7 for ; Thu, 27 Jan 2022 19:09:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3558E427BF; Thu, 27 Jan 2022 19:09:07 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id B76F440141; Thu, 27 Jan 2022 19:09:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643306945; x=1674842945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9hyjfeej38HhT+/r2BuNNyg0iP4qv+DVzxOoRD3bVeA=; b=VZoLrwXiNGe6XIvtCkKLExuWP7BSEM/X8bCCp05BMQPw+OzEWYxY6tus qZHgY32Dsm3baKI7X80iriMNwCimIDjpJ4+i4bIpB/br0J2qPqIR1y6Jf 5mlDdiPjdoyzFB1OGBuSW1xzSvV6GHHoUfHoXwOFbuMhq94kF3bl2bl8e muBvnwit32hjrMqkjJ/bF8INRWVvwY0JxZVpiSuzmbFaLHYTWWUmO0BjS kNrEEkElSW4U9hHYFDlbsY8hfXAcJx8C0XkhxH4PhTDLEL3ZnEJPDsd2l QnXV3CiDinnCN/46r+7EdUZunFjT563OGlVlu73jsDRIn0sCpyPOhWL1x Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10239"; a="226903009" X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="226903009" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 10:09:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="563882486" Received: from silpixa00400072.ir.intel.com (HELO silpixa00400072.ger.corp.intel.com) ([10.237.222.91]) by orsmga001.jf.intel.com with ESMTP; 27 Jan 2022 10:09:02 -0800 From: Vladimir Medvedkin To: dev@dpdk.org Cc: stable@dpdk.org Subject: [PATCH v3] app/test-fib: fix possible division by zero Date: Thu, 27 Jan 2022 18:08:53 +0000 Message-Id: <20220127180853.1131512-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223153742.760838-1-vladimir.medvedkin@intel.com> References: <20211223153742.760838-1-vladimir.medvedkin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org This patch fixes the division by 0, which occurs if the number of routes is less than 10. Can be triggered by passing -n argument with value < 10: ./dpdk-test-fib -- -n 9 ... Floating point exception (core dumped) Fixes: 103809d032cd ("app/test-fib: add test application for FIB") Cc: stable@dpdk.org Signed-off-by: Vladimir Medvedkin --- app/test-fib/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/test-fib/main.c b/app/test-fib/main.c index ecd420116a..067c5284f9 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -711,6 +711,10 @@ parse_opts(int argc, char **argv) print_usage(); rte_exit(-EINVAL, "Invalid option -n\n"); } + + if (config.nb_routes < config.print_fract) + config.print_fract = config.nb_routes; + break; case 'd': distrib_string = optarg; @@ -1242,6 +1246,10 @@ main(int argc, char **argv) config.nb_routes = 0; while (fgets(line, sizeof(line), fr) != NULL) config.nb_routes++; + + if (config.nb_routes < config.print_fract) + config.print_fract = config.nb_routes; + rewind(fr); } -- 2.25.1