From 57833a5dff3a4a542a4c00827e3ed55a807778ea Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Thu, 12 Nov 2020 22:49:47 +0800 Subject: [PATCH] iscsi: fix the warning issue in tgt_node.c reported by vagrant. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Ziye Yang Change-Id: Ib64e7140d5e14909d2a86dd2d47413abe5cd027e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5092 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- lib/iscsi/tgt_node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iscsi/tgt_node.c b/lib/iscsi/tgt_node.c index b91dc1cb0..b91c94964 100644 --- a/lib/iscsi/tgt_node.c +++ b/lib/iscsi/tgt_node.c @@ -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;