Commit c0d6eb9d authored by Ben Walker's avatar Ben Walker
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/407021


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 7552707e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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';
		}
	}