iscsi-target: use strlcpy in iscsit_collect_login_stats
authorJoern Engel <joern@logfs.org>
Tue, 2 Sep 2014 21:49:55 +0000 (17:49 -0400)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 17 Sep 2014 20:54:38 +0000 (13:54 -0700)
last_intr_fail_name is a fixed-size array and could theoretically
overflow.  In reality intrname->value doesn't seem to depend on
untrusted input or be anywhere near 224 characters, so the overflow is
pretty theoretical.  But strlcpy is cheap enough.

Found by coverity.

Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target_util.c

index fd90b28f1d94358db7361899b32928b0d1b5fee2..5d611d7ba2827dc2b8b6df850a9ee2862b65b012 100644 (file)
@@ -1479,8 +1479,9 @@ void iscsit_collect_login_stats(
                if (conn->param_list)
                        intrname = iscsi_find_param_from_key(INITIATORNAME,
                                                             conn->param_list);
-               strcpy(ls->last_intr_fail_name,
-                      (intrname ? intrname->value : "Unknown"));
+               strlcpy(ls->last_intr_fail_name,
+                      (intrname ? intrname->value : "Unknown"),
+                      sizeof(ls->last_intr_fail_name));
 
                ls->last_intr_fail_ip_family = conn->login_family;