Commit 57833a5d authored by Ziye Yang's avatar Ziye Yang Committed by Jim Harris
Browse files

iscsi: fix the warning issue in tgt_node.c reported by vagrant.



The allocated size of buf is too large,i.e., 4096. And we will
have host to be assigned with buf, host = buf. But the tmp_buf (destination)
buffer is not so big. So restrict the buf size and make the vagrant happy.

The max size of conn->target_addr is MAX_TARGET_ADDR, so add additional 2 is enough
according the format to print.

The warning is:

/home/vagrant/spdk_repo/spdk/lib/iscsi/tgt_node.c:377:47: warning: ‘%s’ directive output may be
truncated writing up to 4095 bytes into a region of size 301 [-Wformat-truncation=]
00:03:02.381    377 |     snprintf(tmp_buf, len + 1, "TargetAddress=%s:%s,%d", host, p->port, pg->tag);

Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Change-Id: Ib64e7140d5e14909d2a86dd2d47413abe5cd027e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5092


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 7b0f650c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -330,7 +330,7 @@ iscsi_send_tgt_portals(struct spdk_iscsi_conn *conn,
		       uint8_t *data, int alloc_len, int total,
		       int *previous_completed_len, bool *no_buf_space)
{
	char buf[MAX_TMPBUF];
	char buf[MAX_TARGET_ADDR + 2];
	struct spdk_iscsi_portal_grp *pg;
	struct spdk_iscsi_pg_map *pg_map;
	struct spdk_iscsi_portal *p;