iscsi: Remove all uses of strncpy

strncpy is going to be added to the list of banned functions because
it does not guarantee strings are null terminated.

Change-Id: I5fe2f9e717bb65caf6fa26dca075aa974c7f7173
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/407021
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2018-04-09 16:08:14 -07:00
parent 7552707ef1
commit c0d6eb9d11
2 changed files with 5 additions and 5 deletions

View File

@ -106,7 +106,7 @@ spdk_iscsi_init_grp_add_initiator(struct spdk_iscsi_init_grp *ig, char *name)
if (p != NULL) {
SPDK_WARNLOG("Please use \"%s\" instead of \"%s\"\n", "ANY", "ALL");
SPDK_WARNLOG("Converting \"%s\" to \"%s\" automatically\n", "ALL", "ANY");
strncpy(p, "ANY", 3);
memcpy(p, "ANY", 3);
}
TAILQ_INSERT_TAIL(&ig->initiator_head, iname, tailq);
@ -239,7 +239,7 @@ spdk_iscsi_init_grp_add_netmask(struct spdk_iscsi_init_grp *ig, char *mask)
if (p != NULL) {
SPDK_WARNLOG("Please use \"%s\" instead of \"%s\"\n", "ANY", "ALL");
SPDK_WARNLOG("Converting \"%s\" to \"%s\" automatically\n", "ALL", "ANY");
strncpy(p, "ANY", 3);
memcpy(p, "ANY", 3);
}
TAILQ_INSERT_TAIL(&ig->netmask_head, imask, tailq);

View File

@ -253,7 +253,7 @@ spdk_iscsi_parse_portal(const char *portalstring, struct spdk_iscsi_portal **ip,
SPDK_ERRLOG("malloc() failed for host\n");
goto error_out;
}
strncpy(host, portalstring, len);
memcpy(host, portalstring, len);
host[len] = '\0';
}
@ -288,7 +288,7 @@ spdk_iscsi_parse_portal(const char *portalstring, struct spdk_iscsi_portal **ip,
SPDK_ERRLOG("malloc() failed for port\n");
goto error_out;
}
strncpy(port, p + 1, len);
memcpy(port, p + 1, len);
port[len] = '\0';
}
}
@ -308,7 +308,7 @@ spdk_iscsi_parse_portal(const char *portalstring, struct spdk_iscsi_portal **ip,
SPDK_ERRLOG("malloc() failed for cpumask\n");
goto error_out;
}
strncpy(cpumask, p + 1, len);
memcpy(cpumask, p + 1, len);
cpumask[len] = '\0';
}
}