!2 fix build error with gcc9
Merge pull request !2 from eaglegai/master
This commit is contained in:
commit
d0a6c8ba0f
179
fcoe-utils-fix-gcc9-build-error.patch
Normal file
179
fcoe-utils-fix-gcc9-build-error.patch
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
diff --git a/fcoeadm.c b/fcoeadm.c
|
||||||
|
index 776b4e3..20b01b3 100644
|
||||||
|
--- a/fcoeadm.c
|
||||||
|
+++ b/fcoeadm.c
|
||||||
|
@@ -185,8 +185,10 @@ fcoeadm_action(enum clif_action cmd, char *ifname, enum clif_flags flags)
|
||||||
|
struct clif_sock_info clif_info;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
- if (ifname)
|
||||||
|
- strncpy(data.ifname, ifname, sizeof(data.ifname));
|
||||||
|
+ if (ifname) {
|
||||||
|
+ strncpy(data.ifname, ifname, sizeof(data.ifname) - 1);
|
||||||
|
+ data.ifname[sizeof(data.ifname) - 1] = '\0';
|
||||||
|
+ }
|
||||||
|
else
|
||||||
|
data.ifname[0] = '\0';
|
||||||
|
data.cmd = cmd;
|
||||||
|
@@ -231,7 +233,8 @@ int main(int argc, char *argv[])
|
||||||
|
* This has to be first because the error print macro
|
||||||
|
* expects progname to be valid.
|
||||||
|
*/
|
||||||
|
- strncpy(progname, basename(argv[0]), sizeof(progname));
|
||||||
|
+ strncpy(progname, basename(argv[0]), sizeof(progname) - 1);
|
||||||
|
+ progname[sizeof(progname) - 1] = '\0';
|
||||||
|
|
||||||
|
/* check if we have sysfs */
|
||||||
|
if (fcoe_checkdir(SYSFS_MOUNT)) {
|
||||||
|
diff --git a/fcoemon.c b/fcoemon.c
|
||||||
|
index 9a400c5..9572836 100644
|
||||||
|
--- a/fcoemon.c
|
||||||
|
+++ b/fcoemon.c
|
||||||
|
@@ -518,8 +518,8 @@ static int fcm_read_config_files(void)
|
||||||
|
dp->d_name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
- strncpy(file, CONFIG_DIR "/", sizeof(file));
|
||||||
|
- strncat(file, dp->d_name, sizeof(file) - strlen(file));
|
||||||
|
+ snprintf(file, sizeof(file), "%s/%.*s", CONFIG_DIR,
|
||||||
|
+ (int)(sizeof(file) - strlen(CONFIG_DIR) - 2), dp->d_name);
|
||||||
|
fp = fopen(file, "r");
|
||||||
|
if (!fp) {
|
||||||
|
FCM_LOG_ERR(errno, "Failed to read %s\n", file);
|
||||||
|
@@ -1089,9 +1089,12 @@ static void fcm_vlan_dev_real_dev(char *vlan_ifname, char *real_ifname)
|
||||||
|
|
||||||
|
memset(&ifv, 0, sizeof(ifv));
|
||||||
|
ifv.cmd = GET_VLAN_REALDEV_NAME_CMD;
|
||||||
|
- strncpy(ifv.device1, vlan_ifname, strlen(vlan_ifname)+1);
|
||||||
|
- if (ioctl(fd, SIOCGIFVLAN, &ifv) == 0)
|
||||||
|
- strncpy(real_ifname, ifv.u.device2, strlen(ifv.u.device2)+1);
|
||||||
|
+ strncpy(ifv.device1, vlan_ifname, sizeof(ifv.device1) - 1);
|
||||||
|
+ ifv.device1[sizeof(ifv.device1) - 1] = '\0';
|
||||||
|
+ if (ioctl(fd, SIOCGIFVLAN, &ifv) == 0) {
|
||||||
|
+ strncpy(real_ifname, ifv.u.device2, IFNAMSIZ - 1);
|
||||||
|
+ real_ifname[IFNAMSIZ - 1] = '\0';
|
||||||
|
+ }
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1642,8 +1645,10 @@ static void fcm_process_link_msg(struct ifinfomsg *ip, int len, unsigned type)
|
||||||
|
/* try to find the real device name */
|
||||||
|
real_dev[0] = '\0';
|
||||||
|
fcm_vlan_dev_real_dev(ifname, real_dev);
|
||||||
|
- if (strlen(real_dev))
|
||||||
|
- strncpy(p->real_ifname, real_dev, strlen(real_dev)+1);
|
||||||
|
+ if (strlen(real_dev)) {
|
||||||
|
+ strncpy(p->real_ifname, real_dev, sizeof(p->real_ifname) - 1);
|
||||||
|
+ p->real_ifname[sizeof(p->real_ifname) - 1] = '\0';
|
||||||
|
+ }
|
||||||
|
if (p->ready)
|
||||||
|
update_fcoe_port_state(p, type, operstate,
|
||||||
|
FCP_CFG_IFNAME);
|
||||||
|
@@ -1655,7 +1660,8 @@ static void fcm_process_link_msg(struct ifinfomsg *ip, int len, unsigned type)
|
||||||
|
if (p) {
|
||||||
|
p->ifindex = ifindex;
|
||||||
|
memcpy(p->mac, mac, ETHER_ADDR_LEN);
|
||||||
|
- strncpy(p->real_ifname, ifname, strlen(ifname)+1);
|
||||||
|
+ strncpy(p->real_ifname, ifname, sizeof(p->real_ifname) - 1);
|
||||||
|
+ p->real_ifname[sizeof(p->real_ifname) - 1] = '\0';
|
||||||
|
update_fcoe_port_state(p, type, operstate,
|
||||||
|
FCP_REAL_IFNAME);
|
||||||
|
}
|
||||||
|
@@ -1783,7 +1789,8 @@ static void fcm_process_ieee_msg(struct nlmsghdr *nlh)
|
||||||
|
if (rta_parent->rta_type != DCB_ATTR_IFNAME)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- strncpy(ifname, NLA_DATA(rta_parent), sizeof(ifname));
|
||||||
|
+ strncpy(ifname, NLA_DATA(rta_parent), sizeof(ifname) - 1);
|
||||||
|
+ ifname[sizeof(ifname) - 1] = '\0';
|
||||||
|
ff = fcm_netif_lookup_create(ifname);
|
||||||
|
if (!ff) {
|
||||||
|
FCM_LOG("Processing IEEE message: %s not found or created\n",
|
||||||
|
@@ -3704,7 +3711,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
|
memset(&fcoe_config, 0, sizeof(fcoe_config));
|
||||||
|
|
||||||
|
- strncpy(progname, basename(argv[0]), sizeof(progname));
|
||||||
|
+ strncpy(progname, basename(argv[0]), sizeof(progname) - 1);
|
||||||
|
+ progname[sizeof(progname) - 1] = '\0';
|
||||||
|
sa_log_prefix = progname;
|
||||||
|
sa_log_flags = 0;
|
||||||
|
openlog(sa_log_prefix, LOG_CONS, LOG_DAEMON);
|
||||||
|
diff --git a/fipvlan.c b/fipvlan.c
|
||||||
|
index 7c00c7c..7dec0df 100644
|
||||||
|
--- a/fipvlan.c
|
||||||
|
+++ b/fipvlan.c
|
||||||
|
@@ -448,7 +448,8 @@ static void rtnl_recv_newlink(struct nlmsghdr *nh)
|
||||||
|
else
|
||||||
|
iff->iflink = iff->ifindex;
|
||||||
|
memcpy(iff->mac_addr, RTA_DATA(ifla[IFLA_ADDRESS]), ETHER_ADDR_LEN);
|
||||||
|
- strncpy(iff->ifname, RTA_DATA(ifla[IFLA_IFNAME]), IFNAMSIZ);
|
||||||
|
+ strncpy(iff->ifname, RTA_DATA(ifla[IFLA_IFNAME]), IFNAMSIZ - 1);
|
||||||
|
+ iff->ifname[IFNAMSIZ - 1] = '\0';
|
||||||
|
|
||||||
|
if (ifla[IFLA_LINKINFO]) {
|
||||||
|
parse_linkinfo(linkinfo, ifla[IFLA_LINKINFO]);
|
||||||
|
@@ -541,8 +542,10 @@ static void parse_cmdline(int argc, char **argv)
|
||||||
|
config.start = true;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
- if (optarg && strlen(optarg))
|
||||||
|
- strncpy(config.suffix, optarg, 256);
|
||||||
|
+ if (optarg && strlen(optarg)) {
|
||||||
|
+ strncpy(config.suffix, optarg, 255);
|
||||||
|
+ config.suffix[255] = '0';
|
||||||
|
+ }
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
config.link_retry = strtoul(optarg, NULL, 10);
|
||||||
|
diff --git a/lib/sysfs_hba.c b/lib/sysfs_hba.c
|
||||||
|
index 5cb7fd3..9892c3d 100644
|
||||||
|
--- a/lib/sysfs_hba.c
|
||||||
|
+++ b/lib/sysfs_hba.c
|
||||||
|
@@ -255,10 +255,12 @@ static void get_module_info(const char *pcidev, struct hba_info *info)
|
||||||
|
|
||||||
|
buf[err] = '\0';
|
||||||
|
|
||||||
|
- if (strstr(buf, "module"))
|
||||||
|
+ if (strstr(buf, "module")) {
|
||||||
|
strncpy(info->driver_name,
|
||||||
|
strstr(buf, "module") + strlen("module") + 1,
|
||||||
|
- sizeof(info->driver_name));
|
||||||
|
+ sizeof(info->driver_name) - 1);
|
||||||
|
+ info->driver_name[sizeof(info->driver_name) - 1] = '\0';
|
||||||
|
+ }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -315,7 +317,8 @@ struct port_attributes *get_rport_attribs(const char *rport)
|
||||||
|
if (!pa)
|
||||||
|
goto free_path;
|
||||||
|
|
||||||
|
- strncpy(pa->device_name, rport, sizeof(pa->device_name));
|
||||||
|
+ strncpy(pa->device_name, rport, sizeof(pa->device_name) - 1);
|
||||||
|
+ pa->device_name[sizeof(pa->device_name) - 1] = '\0';
|
||||||
|
sa_sys_read_line(path, "node_name", pa->node_name,
|
||||||
|
sizeof(pa->node_name));
|
||||||
|
sa_sys_read_line(path, "port_name", pa->port_name,
|
||||||
|
@@ -390,7 +393,8 @@ struct port_attributes *get_port_attribs(const char *host)
|
||||||
|
if (!pa)
|
||||||
|
goto free_path;
|
||||||
|
|
||||||
|
- strncpy(pa->device_name, host, sizeof(pa->device_name));
|
||||||
|
+ strncpy(pa->device_name, host, sizeof(pa->device_name) - 1);
|
||||||
|
+ pa->device_name[sizeof(pa->device_name) - 1] = '\0';
|
||||||
|
|
||||||
|
sa_sys_read_line(path, "symbolic_name", pa->symbolic_name,
|
||||||
|
sizeof(pa->symbolic_name));
|
||||||
|
@@ -443,7 +447,7 @@ char *get_pci_dev_from_netdev(const char *netdev)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
len = strlen(netdev) - strlen(subif);
|
||||||
|
- strncpy(realdev, netdev, len);
|
||||||
|
+ strncpy(realdev, netdev, sizeof(realdev) - 1);
|
||||||
|
if (realdev[len] != '\0')
|
||||||
|
realdev[len] = '\0';
|
||||||
|
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: fcoe-utils
|
Name: fcoe-utils
|
||||||
Version: 1.0.32
|
Version: 1.0.32
|
||||||
Release: 7
|
Release: 8
|
||||||
Summary: Fibre Channel over Ethernet utilities
|
Summary: Fibre Channel over Ethernet utilities
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
URL: https://www.open-fcoe.org
|
URL: https://www.open-fcoe.org
|
||||||
@ -10,6 +10,8 @@ Source2: fcoe.service
|
|||||||
Source3: fcoe.config
|
Source3: fcoe.config
|
||||||
Patch0: fcoe-utils-gcc7-fmt-truc-err.patch
|
Patch0: fcoe-utils-gcc7-fmt-truc-err.patch
|
||||||
Patch1: fcoe-utils-gcc8-fmt-truc-err.patch
|
Patch1: fcoe-utils-gcc8-fmt-truc-err.patch
|
||||||
|
#This patch refer to ubuntu's version
|
||||||
|
Patch2: fcoe-utils-fix-gcc9-build-error.patch
|
||||||
|
|
||||||
BuildRequires: autoconf automake libpciaccess-devel libtool lldpad-devel systemd
|
BuildRequires: autoconf automake libpciaccess-devel libtool lldpad-devel systemd
|
||||||
Requires: lldpad iproute device-mapper-multipath
|
Requires: lldpad iproute device-mapper-multipath
|
||||||
@ -69,6 +71,12 @@ rm -f %{buildroot}/%{_sysconfdir}/fcoe/config
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jun 23 2020 gaihuiying <gaihuiying1@huawei.com> - 1.0.32-8
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:fix build error with gcc9 about strncpy
|
||||||
|
|
||||||
* Fri Oct 11 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.0.32-7
|
* Fri Oct 11 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.0.32-7
|
||||||
- Package init
|
- Package init
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user