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 96BED45681; Mon, 22 Jul 2024 15:50:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 543384067B; Mon, 22 Jul 2024 15:50:53 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by mails.dpdk.org (Postfix) with ESMTP id 873C1402A8 for ; Mon, 22 Jul 2024 15:50:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721656252; x=1753192252; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pLf0IzYksPP8odQQQ+vdHoc0pPLdyIWdvCkSwpjiZF4=; b=LvfQjZf8Im/r2GuhCiw7EgEKoSO4WCmlY3WZnw8QMzwlq+W7dAXmEaUk jTRCPbqEGDHIwIdi7lvHeXDVF10jTHorgqYPGZk8MayYasgyLv5ER3I++ SLtZheTB/j5PSSmVfy/rBpJr0R7o0R2r8lN4Ptctm6qLINqHvUUWAV59R dGwtyDs4e4X0UMEx0D0AjwCCbLIOeNOfrHPokstBkNXcUvqfnlCoE9Ktp r0SbZrxC03YhR9VjupJTBZY9AMiXPO5ZFvy6+wrEUL64SzPwFWX8cQFns 3SbvZdUlobwth8BouCN7v1YR99QP3tKvCZb2ttb8R7U76JAnlxwKsmK6k A==; X-CSE-ConnectionGUID: I8VlK7KoT4miQgFpaSf6/g== X-CSE-MsgGUID: lqwxSU3kRSCZOk+X2ZZG7g== X-IronPort-AV: E=McAfee;i="6700,10204,11140"; a="19354997" X-IronPort-AV: E=Sophos;i="6.09,228,1716274800"; d="scan'208";a="19354997" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2024 06:50:51 -0700 X-CSE-ConnectionGUID: yHtE7FmzTJiC+PqJgmmzrQ== X-CSE-MsgGUID: tlUDwwU2QAel8fn62rVPhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,228,1716274800"; d="scan'208";a="52494940" Received: from unknown (HELO silpixa00401176.ir.intel.com) ([10.243.22.170]) by orviesa007.jf.intel.com with ESMTP; 22 Jul 2024 06:50:50 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: bruce.richardson@intel.com Subject: [PATCH v5 2/3] net/ice: refactor raw pattern parsing function Date: Mon, 22 Jul 2024 13:50:45 +0000 Message-Id: <20240722135046.285868-2-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722135046.285868-1-vladimir.medvedkin@intel.com> References: <20240722105950.199804-1-vladimir.medvedkin@intel.com> <20240722135046.285868-1-vladimir.medvedkin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace strlen with more secure strnlen in ice_hash_parse_raw_pattern. Signed-off-by: Vladimir Medvedkin tmp --- drivers/net/ice/ice_hash.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index 6b3095e2c5..aa76718313 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -658,10 +658,13 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, raw_spec = item->spec; raw_mask = item->mask; - spec_len = strlen((char *)(uintptr_t)raw_spec->pattern); - if (strlen((char *)(uintptr_t)raw_mask->pattern) != - spec_len) - return -rte_errno; + spec_len = strnlen((char *)(uintptr_t)raw_spec->pattern, + raw_spec->length + 1); + if (spec_len != raw_spec->length) + return -EINVAL; + if (strnlen((char *)(uintptr_t)raw_mask->pattern, raw_spec->length + 1) != + spec_len) + return -EINVAL; pkt_len = spec_len / 2; -- 2.34.1