app/crypto-perf: fix string not null terminated

This commit fixes the case where the string buffer may not have
a null terminator if the source string's length is equal to the
buffer size.

Coverity issue: 141069
Fixes: f8be1786b1 ("app/crypto-perf: introduce performance test application")

Signed-off-by: Aleksander Gajewski <aleksanderx.gajewski@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
This commit is contained in:
Aleksander Gajewski 2017-02-07 10:20:18 +01:00 committed by Pablo de Lara
parent b75a76d354
commit 8ecd4048ba

View File

@ -198,7 +198,8 @@ parse_device_type(struct cperf_options *opts, const char *arg)
if (strlen(arg) > (sizeof(opts->device_type) - 1))
return -1;
strncpy(opts->device_type, arg, sizeof(opts->device_type));
strncpy(opts->device_type, arg, sizeof(opts->device_type) - 1);
*(opts->device_type + sizeof(opts->device_type) - 1) = '\0';
return 0;
}