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