From patchwork Fri Feb 10 14:22:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slawomir Mrozowicz X-Patchwork-Id: 20372 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id F217C9E7; Fri, 10 Feb 2017 13:29:08 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 025FD3B5 for ; Fri, 10 Feb 2017 13:29:05 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Feb 2017 04:28:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,141,1484035200"; d="scan'208"; a="1105631956" Received: from gklab-246-019.igk.intel.com (HELO intel.com) ([10.217.246.19]) by fmsmga001.fm.intel.com with SMTP; 10 Feb 2017 04:28:56 -0800 Received: by intel.com (sSMTP sendmail emulation); Fri, 10 Feb 2017 15:22:32 +0100 From: Slawomir Mrozowicz To: declan.doherty@intel.com Cc: dev@dpdk.org, Slawomir Mrozowicz Date: Fri, 10 Feb 2017 15:22:30 +0100 Message-Id: <1486736550-5583-1-git-send-email-slawomirx.mrozowicz@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486392910-8183-1-git-send-email-slawomirx.mrozowicz@intel.com> References: <1486392910-8183-1-git-send-email-slawomirx.mrozowicz@intel.com> Subject: [dpdk-dev] [PATCH v2] app/crypto-perf: fix dereference null return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Dereferencing a pointer that might be null key_token when calling strstr. Check if the pointer is null before. Coverity issue: 141071 Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Signed-off-by: Slawomir Mrozowicz Acked-by: Pablo de Lara --- v2 changes: - print message only if key_token exist --- app/test-crypto-perf/cperf_test_vector_parsing.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c index e0bcb20..e442489 100644 --- a/app/test-crypto-perf/cperf_test_vector_parsing.c +++ b/app/test-crypto-perf/cperf_test_vector_parsing.c @@ -234,15 +234,19 @@ parse_entry(char *entry, struct cperf_test_vector *vector, uint8_t *data = NULL; char *token, *key_token; + if (entry == NULL) { + printf("Expected entry value\n"); + return -1; + } + /* get key */ token = strtok(entry, CPERF_ENTRY_DELIMITER); key_token = token; - /* get values for key */ token = strtok(NULL, CPERF_ENTRY_DELIMITER); - if (token == NULL) { - printf("Expected 'key = values' but was '%.40s'..\n", - key_token); + + if (key_token == NULL || token == NULL) { + printf("Expected 'key = values' but was '%.40s'..\n", entry); return -1; }