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