From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id DD1E82E83 for ; Tue, 12 Apr 2016 12:03:59 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 12 Apr 2016 03:04:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,473,1455004800"; d="scan'208";a="783138660" Received: from sie-lab-214-036.ir.intel.com (HELO sie-lab-214-36.ir.intel.com) ([10.237.214.36]) by orsmga003.jf.intel.com with ESMTP; 12 Apr 2016 03:03:57 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: declan.doherty@intel.com, Pablo de Lara Date: Tue, 12 Apr 2016 11:04:03 +0100 Message-Id: <1460455443-11130-1-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2016 10:04:00 -0000 When initializing crypto devices within the app, the provided key sizes are checked against the supported sizes from the crypto device capabilities. When the supported sizes are not a range, but a single value, the check may become an infinite loop (when size is not supported). Fixes: a061e50a0d97 ("examples/l2fwd-crypto: fix ambiguous input key size") Signed-off-by: Pablo de Lara --- examples/l2fwd-crypto/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index d4e2d8d..e273f2f 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1486,6 +1486,15 @@ check_supported_size(uint16_t length, uint16_t min, uint16_t max, { uint16_t supp_size; + /* Single value */ + if (increment == 0) { + if (length == min) + return 0; + else + return -1; + } + + /* Range of values */ for (supp_size = min; supp_size <= max; supp_size += increment) { if (length == supp_size) return 0; -- 2.5.5