[dpdk-dev] [PATCH] app/crypto-perf: fix dereference null return value

De Lara Guarch, Pablo pablo.de.lara.guarch at intel.com
Thu Feb 9 23:31:31 CET 2017


Hi Slawomir,

> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Slawomir
> Mrozowicz
> Sent: Monday, February 06, 2017 2:55 PM
> To: Doherty, Declan
> Cc: dev at dpdk.org; Mrozowicz, SlawomirX
> Subject: [dpdk-dev] [PATCH] app/crypto-perf: fix dereference null return
> value
> 
> 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 <slawomirx.mrozowicz at intel.com>
> ---
>  app/test-crypto-perf/cperf_test_vector_parsing.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-
> crypto-perf/cperf_test_vector_parsing.c
> index e0bcb20..a7d7b51 100644
> --- a/app/test-crypto-perf/cperf_test_vector_parsing.c
> +++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
> @@ -240,7 +240,7 @@ parse_entry(char *entry, struct cperf_test_vector
> *vector,
> 
>  	/* get values for key */
>  	token = strtok(NULL, CPERF_ENTRY_DELIMITER);
> -	if (token == NULL) {
> +	if (key_token == NULL || token == NULL) {

Is this fix right? If key_token is NULL, then I would expect a seg fault here.

>  		printf("Expected 'key = values' but was '%.40s'..\n",
>  			key_token);
>  		return -1;
> --
> 2.5.0

Thanks,
Pablo


More information about the dev mailing list