Commit 0a638e9d authored by Marcin Spiewak's avatar Marcin Spiewak Committed by Jim Harris
Browse files

bdevperf: avoid using of out of boundary indices



This patch corrects patch 17176, which doesn't
corectly addresses issue found by Klocwork scan.
Both indices, k and i, needs to be verified here,
as both *filename and *out has limited size.
As the 'k' index is incremented inside the loop,
the loop entry condition for k index must be set to
k < (BDEVPERF_CONFIG_MAX_FILENAME - 1) not to
k < BDEVPERF_CONFIG_MAX_FILENAME,
to avoid situation where i and k are both equal to
BDEVPERF_CONFIG_MAX_FILENAME - 1, 'for' loop pass
is therefore executed, and inside the loop k is
incremented (so it is set to
k=BDEVPERF_CONFIG_MAX_FILENAME) giving in result
out of boundary index for *out table in line:
out[k] = 0;

Change-Id: Idf62c40f86f3aa4c8c6372bc74e94703925de47e
Signed-off-by: default avatarMarcin Spiewak <marcin.spiewak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18135


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 508531e1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1865,7 +1865,8 @@ config_filename_next(const char *filename, char *out)
	for (i = 0, k = 0;
	     filename[i] != '\0' &&
	     filename[i] != ':' &&
	     k < BDEVPERF_CONFIG_MAX_FILENAME;
	     i < BDEVPERF_CONFIG_MAX_FILENAME &&
	     k < (BDEVPERF_CONFIG_MAX_FILENAME - 1);
	     i++) {
		if (filename[i] == ' ' || filename[i] == '\t') {
			continue;