From: Slawomir Mrozowicz Date: Fri, 10 Feb 2017 14:22:30 +0000 (+0100) Subject: app/crypto-perf: fix null dereference X-Git-Tag: spdx-start~4501 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=559ef9201a9e28b75208b438a88b49b3085d664b;p=dpdk.git app/crypto-perf: fix null dereference 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 --- diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c index c53ba67875..d1c01d27a2 100644 --- a/app/test-crypto-perf/cperf_test_vector_parsing.c +++ b/app/test-crypto-perf/cperf_test_vector_parsing.c @@ -237,15 +237,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; }