iscsi: Use fixed size string for host and port name of connection

This will reduce the potential malloc failure.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ibcd631bf318ef6ece4ac337219652323ca5fd8f1
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464136
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-08-08 14:59:30 +09:00 committed by Jim Harris
parent 20bbd038aa
commit 23eb38f1ac
2 changed files with 6 additions and 6 deletions

View File

@ -99,8 +99,8 @@ allocate_conn(void)
static void
free_conn(struct spdk_iscsi_conn *conn)
{
free(conn->portal_host);
free(conn->portal_port);
memset(conn->portal_host, 0, sizeof(conn->portal_host));
memset(conn->portal_port, 0, sizeof(conn->portal_port));
conn->is_valid = 0;
}
@ -227,8 +227,8 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
conn->portal = portal;
conn->pg_tag = portal->group->tag;
conn->portal_host = strdup(portal->host);
conn->portal_port = strdup(portal->port);
memcpy(conn->portal_host, portal->host, strlen(portal->host));
memcpy(conn->portal_port, portal->port, strlen(portal->port));
conn->sock = sock;
conn->state = ISCSI_CONN_STATE_INVALID;

View File

@ -80,8 +80,8 @@ struct spdk_iscsi_conn {
*/
struct spdk_iscsi_portal *portal;
int pg_tag;
char *portal_host;
char *portal_port;
char portal_host[MAX_PORTAL_ADDR + 1];
char portal_port[MAX_PORTAL_ADDR + 1];
struct spdk_iscsi_poll_group *pg;
struct spdk_sock *sock;
struct spdk_iscsi_sess *sess;