Blame SOURCES/0164-libiscsi-fix-incorrect-strncpy-use.patch

e88930
From fcad7de1a8c3d140d1d0eb120727966017d3727b Mon Sep 17 00:00:00 2001
e88930
From: Chris Leech <cleech@redhat.com>
e88930
Date: Sat, 17 Aug 2013 15:50:45 -0700
e88930
Subject: libiscsi: fix incorrect strncpy use
e88930
e88930
Changes to internal structures make the src and dst buffers of some
e88930
copies (potentially) different sizes.  Fix strncpy calls that were using
e88930
the size of the src argument as the limit.
e88930
---
e88930
 libiscsi/libiscsi.c | 19 ++++++++-----------
e88930
 1 file changed, 8 insertions(+), 11 deletions(-)
e88930
e88930
diff --git a/libiscsi/libiscsi.c b/libiscsi/libiscsi.c
e88930
index 6e6846a..064e4b5 100644
e88930
--- a/libiscsi/libiscsi.c
e88930
+++ b/libiscsi/libiscsi.c
e88930
@@ -587,15 +587,13 @@ int libiscsi_get_firmware_network_config(
e88930
 		return ENODEV;
e88930
 
e88930
 	config->dhcp = strlen(fw_entry.dhcp) ? 1 : 0;
e88930
-	strncpy(config->iface_name, fw_entry.iface, sizeof fw_entry.iface);
e88930
-	strncpy(config->mac_address, fw_entry.mac, sizeof fw_entry.mac);
e88930
-	strncpy(config->ip_address, fw_entry.ipaddr, sizeof fw_entry.ipaddr);
e88930
-	strncpy(config->netmask, fw_entry.mask, sizeof fw_entry.mask);
e88930
-	strncpy(config->gateway, fw_entry.gateway, sizeof fw_entry.gateway);
e88930
-	strncpy(config->primary_dns, fw_entry.primary_dns,
e88930
-		sizeof fw_entry.primary_dns);
e88930
-	strncpy(config->secondary_dns, fw_entry.secondary_dns,
e88930
-		sizeof fw_entry.secondary_dns);
e88930
+	strlcpy(config->iface_name, fw_entry.iface, LIBISCSI_VALUE_MAXLEN);
e88930
+	strlcpy(config->mac_address, fw_entry.mac, LIBISCSI_VALUE_MAXLEN);
e88930
+	strlcpy(config->ip_address, fw_entry.ipaddr, LIBISCSI_VALUE_MAXLEN);
e88930
+	strlcpy(config->netmask, fw_entry.mask, LIBISCSI_VALUE_MAXLEN);
e88930
+	strlcpy(config->gateway, fw_entry.gateway, LIBISCSI_VALUE_MAXLEN);
e88930
+	strlcpy(config->primary_dns, fw_entry.primary_dns, LIBISCSI_VALUE_MAXLEN);
e88930
+	strlcpy(config->secondary_dns, fw_entry.secondary_dns, LIBISCSI_VALUE_MAXLEN);
e88930
 	return 0;
e88930
 }
e88930
 
e88930
@@ -613,8 +611,7 @@ int libiscsi_get_firmware_initiator_name(char *initiatorname)
e88930
 	if (fw_get_entry(&fw_entry))
e88930
 		return ENODEV;
e88930
 
e88930
-	strncpy(initiatorname, fw_entry.initiatorname,
e88930
-		sizeof fw_entry.initiatorname);
e88930
+	strlcpy(initiatorname, fw_entry.initiatorname, LIBISCSI_VALUE_MAXLEN);
e88930
 
e88930
 	return 0;
e88930
 }
e88930
-- 
e88930
1.8.1.4
e88930