Skip to content

Commit

Permalink
iscsi-target: Fix snprintf usage with MAX_PORTAL_LEN
Browse files Browse the repository at this point in the history
This patch makes lio_target_call_addnptotpg() use sprintf() with
MAX_PORTAL_LEN + 1 to address the following smatch warning:

drivers/target/iscsi/iscsi_target_configfs.c +184 lio_target_call_addnptotpg(21)
        error: snprintf() chops off the last chars of 'name': 257 vs 256

Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Nicholas Bellinger committed Jul 27, 2011
1 parent 76f1928 commit 7bbb654
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/target/iscsi/iscsi_target_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ struct se_tpg_np *lio_target_call_addnptotpg(
return ERR_PTR(-EOVERFLOW);
}
memset(buf, 0, MAX_PORTAL_LEN + 1);
snprintf(buf, MAX_PORTAL_LEN, "%s", name);
snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);

memset(&sockaddr, 0, sizeof(struct __kernel_sockaddr_storage));

Expand Down

0 comments on commit 7bbb654

Please sign in to comment.