From e72b21197129ce2daea2e48bfe81b448cfd9adf8 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 28 2023 09:04:38 +0000 Subject: import iputils-20210202-8.el9 --- diff --git a/SOURCES/100-iputils-ifenslave.patch b/SOURCES/100-iputils-ifenslave.patch new file mode 100644 index 0000000..662d69d --- /dev/null +++ b/SOURCES/100-iputils-ifenslave.patch @@ -0,0 +1,13 @@ +--- iputils/ifenslave.c.addr 2006-03-29 15:00:24.000000000 +0200 ++++ iputils/ifenslave.c 2006-03-29 15:02:01.000000000 +0200 +@@ -524,8 +524,8 @@ + if (ioctl(skfd, SIOCGIFADDR, &ifr) < 0) + return -1; + printf("The result of SIOCGIFADDR is %2.2x.%2.2x.%2.2x.%2.2x.\n", +- ifr.ifr_addr.sa_data[0], ifr.ifr_addr.sa_data[1], +- ifr.ifr_addr.sa_data[2], ifr.ifr_addr.sa_data[3]); ++ ifr.ifr_addr.sa_data[2], ifr.ifr_addr.sa_data[3], ++ ifr.ifr_addr.sa_data[4], ifr.ifr_addr.sa_data[5]); + + strcpy(ifr.ifr_name, ifname); + if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) diff --git a/SOURCES/101-iputils-ifenslave-CWE-170.patch b/SOURCES/101-iputils-ifenslave-CWE-170.patch new file mode 100644 index 0000000..c81b700 --- /dev/null +++ b/SOURCES/101-iputils-ifenslave-CWE-170.patch @@ -0,0 +1,88 @@ +From a38091c8eb0c515441080806975856ee09d2edc7 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 23 Mar 2021 08:10:10 +0100 +Subject: [PATCH] ifenslave: fix CWE-170: Improper Null Termination + +--- + ifenslave.c | 24 ++++++++++++++++-------- + 1 file changed, 16 insertions(+), 8 deletions(-) + +diff --git a/ifenslave.c b/ifenslave.c +index ddd82ec..1efe4f1 100644 +--- a/ifenslave.c ++++ b/ifenslave.c +@@ -509,21 +509,24 @@ static int if_getconfig(char *ifname) + struct sockaddr dstaddr, broadaddr, netmask; + unsigned char *hwaddr; + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) + return -1; + mif_flags = ifr.ifr_flags; + printf("The result of SIOCGIFFLAGS on %s is %x.\n", + ifname, ifr.ifr_flags); + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFADDR, &ifr) < 0) + return -1; + printf("The result of SIOCGIFADDR is %2.2x.%2.2x.%2.2x.%2.2x.\n", + ifr.ifr_addr.sa_data[2], ifr.ifr_addr.sa_data[3], + ifr.ifr_addr.sa_data[4], ifr.ifr_addr.sa_data[5]); + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) + return -1; + +@@ -534,33 +537,38 @@ static int if_getconfig(char *ifname) + ifr.ifr_hwaddr.sa_family, hwaddr[0], hwaddr[1], + hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFMETRIC, &ifr) < 0) { + metric = 0; + } else + metric = ifr.ifr_metric; + printf("The result of SIOCGIFMETRIC is %d\n", metric); + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0) + mtu = 0; + else + mtu = ifr.ifr_mtu; + printf("The result of SIOCGIFMTU is %d\n", mtu); + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFDSTADDR, &ifr) < 0) { + memset(&dstaddr, 0, sizeof(struct sockaddr)); + } else + dstaddr = ifr.ifr_dstaddr; + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFBRDADDR, &ifr) < 0) { + memset(&broadaddr, 0, sizeof(struct sockaddr)); + } else + broadaddr = ifr.ifr_broadaddr; + +- strcpy(ifr.ifr_name, ifname); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + if (ioctl(skfd, SIOCGIFNETMASK, &ifr) < 0) { + memset(&netmask, 0, sizeof(struct sockaddr)); + } else +-- +2.29.2 + diff --git a/SOURCES/102-iputils-ifenslave-CWE-170-2.patch b/SOURCES/102-iputils-ifenslave-CWE-170-2.patch new file mode 100644 index 0000000..67e6a5e --- /dev/null +++ b/SOURCES/102-iputils-ifenslave-CWE-170-2.patch @@ -0,0 +1,154 @@ +From bea19fd9a86dd2c601681ff2ef4a9c1afab1e34d Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 8 Jun 2021 15:41:58 +0200 +Subject: [PATCH] ifenslave: fix CWE-170: Improper Null Termination + +Resolves: #1938746 +--- + ifenslave.c | 43 +++++++++++++++++++++++++++---------------- + 1 file changed, 27 insertions(+), 16 deletions(-) + +diff --git a/ifenslave.c b/ifenslave.c +index 1efe4f1..59bce4c 100644 +--- a/ifenslave.c ++++ b/ifenslave.c +@@ -619,7 +619,7 @@ static int get_drv_info(char *master_ifname) + char *endptr; + + memset(&ifr, 0, sizeof(ifr)); +- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); ++ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); + ifr.ifr_data = (caddr_t)&info; + + info.cmd = ETHTOOL_GDRVINFO; +@@ -664,8 +664,9 @@ static int change_active(char *master_ifname, char *slave_ifname) + return 1; + } + +- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); +- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); ++ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1); + if ((ioctl(skfd, SIOCBONDCHANGEACTIVE, &ifr) < 0) && + (ioctl(skfd, BOND_CHANGE_ACTIVE_OLD, &ifr) < 0)) { + saved_errno = errno; +@@ -806,8 +807,9 @@ static int enslave(char *master_ifname, char *slave_ifname) + } + + /* Do the real thing */ +- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); +- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); ++ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1); + if ((ioctl(skfd, SIOCBONDENSLAVE, &ifr) < 0) && + (ioctl(skfd, BOND_ENSLAVE_OLD, &ifr) < 0)) { + saved_errno = errno; +@@ -847,8 +849,9 @@ static int release(char *master_ifname, char *slave_ifname) + return 1; + } + +- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); +- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); ++ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1); + if ((ioctl(skfd, SIOCBONDRELEASE, &ifr) < 0) && + (ioctl(skfd, BOND_RELEASE_OLD, &ifr) < 0)) { + saved_errno = errno; +@@ -880,7 +883,8 @@ static int get_if_settings(char *ifname, struct dev_ifr ifra[]) + int res = 0; + + for (i = 0; ifra[i].req_ifr; i++) { +- strncpy(ifra[i].req_ifr->ifr_name, ifname, IFNAMSIZ); ++ strncpy(ifra[i].req_ifr->ifr_name, ifname, IFNAMSIZ - 1); ++ ifra[i].req_ifr->ifr_name[IFNAMSIZ - 1] = '\0'; + res = ioctl(skfd, ifra[i].req_type, ifra[i].req_ifr); + if (res < 0) { + saved_errno = errno; +@@ -899,7 +903,8 @@ static int get_slave_flags(char *slave_ifname) + { + int res = 0; + +- strncpy(slave_flags.ifr_name, slave_ifname, IFNAMSIZ); ++ strncpy(slave_flags.ifr_name, slave_ifname, IFNAMSIZ - 1); ++ slave_flags.ifr_name[IFNAMSIZ - 1] = '\0'; + res = ioctl(skfd, SIOCGIFFLAGS, &slave_flags); + if (res < 0) { + saved_errno = errno; +@@ -919,7 +924,8 @@ static int set_master_hwaddr(char *master_ifname, struct sockaddr *hwaddr) + struct ifreq ifr; + int res = 0; + +- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); + memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr)); + res = ioctl(skfd, SIOCSIFHWADDR, &ifr); + if (res < 0) { +@@ -943,7 +949,8 @@ static int set_slave_hwaddr(char *slave_ifname, struct sockaddr *hwaddr) + struct ifreq ifr; + int res = 0; + +- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1); + memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr)); + res = ioctl(skfd, SIOCSIFHWADDR, &ifr); + if (res < 0) { +@@ -980,8 +987,9 @@ static int set_slave_mtu(char *slave_ifname, int mtu) + struct ifreq ifr; + int res = 0; + ++ memset(&ifr, 0, sizeof(ifr)); + ifr.ifr_mtu = mtu; +- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ); ++ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1); + + res = ioctl(skfd, SIOCSIFMTU, &ifr); + if (res < 0) { +@@ -1000,8 +1008,9 @@ static int set_if_flags(char *ifname, short flags) + struct ifreq ifr; + int res = 0; + ++ memset(&ifr, 0, sizeof(ifr)); + ifr.ifr_flags = flags; +- strncpy(ifr.ifr_name, ifname, IFNAMSIZ); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + + res = ioctl(skfd, SIOCSIFFLAGS, &ifr); + if (res < 0) { +@@ -1030,7 +1039,8 @@ static int clear_if_addr(char *ifname) + struct ifreq ifr; + int res = 0; + +- strncpy(ifr.ifr_name, ifname, IFNAMSIZ); ++ memset(&ifr, 0, sizeof(ifr)); ++ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); + ifr.ifr_addr.sa_family = AF_INET; + memset(ifr.ifr_addr.sa_data, 0, sizeof(ifr.ifr_addr.sa_data)); + +@@ -1065,8 +1075,9 @@ static int set_if_addr(char *master_ifname, char *slave_ifname) + {NULL, NULL, 0, 0}, + }; + ++ memset(&ifr, 0, sizeof(ifr)); + for (i = 0; ifra[i].req_name; i++) { +- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); ++ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); + res = ioctl(skfd, ifra[i].g_ioctl, &ifr); + if (res < 0) { + int saved_errno = errno; +@@ -1080,7 +1091,7 @@ static int set_if_addr(char *master_ifname, char *slave_ifname) + sizeof(ifr.ifr_addr.sa_data)); + } + +- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ); ++ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1); + res = ioctl(skfd, ifra[i].s_ioctl, &ifr); + if (res < 0) { + int saved_errno = errno; +-- +2.31.1 + diff --git a/SOURCES/iputils-ifenslave-CWE-170-2.patch b/SOURCES/iputils-ifenslave-CWE-170-2.patch deleted file mode 100644 index 67e6a5e..0000000 --- a/SOURCES/iputils-ifenslave-CWE-170-2.patch +++ /dev/null @@ -1,154 +0,0 @@ -From bea19fd9a86dd2c601681ff2ef4a9c1afab1e34d Mon Sep 17 00:00:00 2001 -From: Jan Macku -Date: Tue, 8 Jun 2021 15:41:58 +0200 -Subject: [PATCH] ifenslave: fix CWE-170: Improper Null Termination - -Resolves: #1938746 ---- - ifenslave.c | 43 +++++++++++++++++++++++++++---------------- - 1 file changed, 27 insertions(+), 16 deletions(-) - -diff --git a/ifenslave.c b/ifenslave.c -index 1efe4f1..59bce4c 100644 ---- a/ifenslave.c -+++ b/ifenslave.c -@@ -619,7 +619,7 @@ static int get_drv_info(char *master_ifname) - char *endptr; - - memset(&ifr, 0, sizeof(ifr)); -- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); -+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); - ifr.ifr_data = (caddr_t)&info; - - info.cmd = ETHTOOL_GDRVINFO; -@@ -664,8 +664,9 @@ static int change_active(char *master_ifname, char *slave_ifname) - return 1; - } - -- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); -- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); -+ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1); - if ((ioctl(skfd, SIOCBONDCHANGEACTIVE, &ifr) < 0) && - (ioctl(skfd, BOND_CHANGE_ACTIVE_OLD, &ifr) < 0)) { - saved_errno = errno; -@@ -806,8 +807,9 @@ static int enslave(char *master_ifname, char *slave_ifname) - } - - /* Do the real thing */ -- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); -- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); -+ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1); - if ((ioctl(skfd, SIOCBONDENSLAVE, &ifr) < 0) && - (ioctl(skfd, BOND_ENSLAVE_OLD, &ifr) < 0)) { - saved_errno = errno; -@@ -847,8 +849,9 @@ static int release(char *master_ifname, char *slave_ifname) - return 1; - } - -- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); -- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); -+ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1); - if ((ioctl(skfd, SIOCBONDRELEASE, &ifr) < 0) && - (ioctl(skfd, BOND_RELEASE_OLD, &ifr) < 0)) { - saved_errno = errno; -@@ -880,7 +883,8 @@ static int get_if_settings(char *ifname, struct dev_ifr ifra[]) - int res = 0; - - for (i = 0; ifra[i].req_ifr; i++) { -- strncpy(ifra[i].req_ifr->ifr_name, ifname, IFNAMSIZ); -+ strncpy(ifra[i].req_ifr->ifr_name, ifname, IFNAMSIZ - 1); -+ ifra[i].req_ifr->ifr_name[IFNAMSIZ - 1] = '\0'; - res = ioctl(skfd, ifra[i].req_type, ifra[i].req_ifr); - if (res < 0) { - saved_errno = errno; -@@ -899,7 +903,8 @@ static int get_slave_flags(char *slave_ifname) - { - int res = 0; - -- strncpy(slave_flags.ifr_name, slave_ifname, IFNAMSIZ); -+ strncpy(slave_flags.ifr_name, slave_ifname, IFNAMSIZ - 1); -+ slave_flags.ifr_name[IFNAMSIZ - 1] = '\0'; - res = ioctl(skfd, SIOCGIFFLAGS, &slave_flags); - if (res < 0) { - saved_errno = errno; -@@ -919,7 +924,8 @@ static int set_master_hwaddr(char *master_ifname, struct sockaddr *hwaddr) - struct ifreq ifr; - int res = 0; - -- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); - memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr)); - res = ioctl(skfd, SIOCSIFHWADDR, &ifr); - if (res < 0) { -@@ -943,7 +949,8 @@ static int set_slave_hwaddr(char *slave_ifname, struct sockaddr *hwaddr) - struct ifreq ifr; - int res = 0; - -- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1); - memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr)); - res = ioctl(skfd, SIOCSIFHWADDR, &ifr); - if (res < 0) { -@@ -980,8 +987,9 @@ static int set_slave_mtu(char *slave_ifname, int mtu) - struct ifreq ifr; - int res = 0; - -+ memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_mtu = mtu; -- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ); -+ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1); - - res = ioctl(skfd, SIOCSIFMTU, &ifr); - if (res < 0) { -@@ -1000,8 +1008,9 @@ static int set_if_flags(char *ifname, short flags) - struct ifreq ifr; - int res = 0; - -+ memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_flags = flags; -- strncpy(ifr.ifr_name, ifname, IFNAMSIZ); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - - res = ioctl(skfd, SIOCSIFFLAGS, &ifr); - if (res < 0) { -@@ -1030,7 +1039,8 @@ static int clear_if_addr(char *ifname) - struct ifreq ifr; - int res = 0; - -- strncpy(ifr.ifr_name, ifname, IFNAMSIZ); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - ifr.ifr_addr.sa_family = AF_INET; - memset(ifr.ifr_addr.sa_data, 0, sizeof(ifr.ifr_addr.sa_data)); - -@@ -1065,8 +1075,9 @@ static int set_if_addr(char *master_ifname, char *slave_ifname) - {NULL, NULL, 0, 0}, - }; - -+ memset(&ifr, 0, sizeof(ifr)); - for (i = 0; ifra[i].req_name; i++) { -- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ); -+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1); - res = ioctl(skfd, ifra[i].g_ioctl, &ifr); - if (res < 0) { - int saved_errno = errno; -@@ -1080,7 +1091,7 @@ static int set_if_addr(char *master_ifname, char *slave_ifname) - sizeof(ifr.ifr_addr.sa_data)); - } - -- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ); -+ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1); - res = ioctl(skfd, ifra[i].s_ioctl, &ifr); - if (res < 0) { - int saved_errno = errno; --- -2.31.1 - diff --git a/SOURCES/iputils-ifenslave-CWE-170.patch b/SOURCES/iputils-ifenslave-CWE-170.patch deleted file mode 100644 index c81b700..0000000 --- a/SOURCES/iputils-ifenslave-CWE-170.patch +++ /dev/null @@ -1,88 +0,0 @@ -From a38091c8eb0c515441080806975856ee09d2edc7 Mon Sep 17 00:00:00 2001 -From: Jan Macku -Date: Tue, 23 Mar 2021 08:10:10 +0100 -Subject: [PATCH] ifenslave: fix CWE-170: Improper Null Termination - ---- - ifenslave.c | 24 ++++++++++++++++-------- - 1 file changed, 16 insertions(+), 8 deletions(-) - -diff --git a/ifenslave.c b/ifenslave.c -index ddd82ec..1efe4f1 100644 ---- a/ifenslave.c -+++ b/ifenslave.c -@@ -509,21 +509,24 @@ static int if_getconfig(char *ifname) - struct sockaddr dstaddr, broadaddr, netmask; - unsigned char *hwaddr; - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) - return -1; - mif_flags = ifr.ifr_flags; - printf("The result of SIOCGIFFLAGS on %s is %x.\n", - ifname, ifr.ifr_flags); - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFADDR, &ifr) < 0) - return -1; - printf("The result of SIOCGIFADDR is %2.2x.%2.2x.%2.2x.%2.2x.\n", - ifr.ifr_addr.sa_data[2], ifr.ifr_addr.sa_data[3], - ifr.ifr_addr.sa_data[4], ifr.ifr_addr.sa_data[5]); - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) - return -1; - -@@ -534,33 +537,38 @@ static int if_getconfig(char *ifname) - ifr.ifr_hwaddr.sa_family, hwaddr[0], hwaddr[1], - hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFMETRIC, &ifr) < 0) { - metric = 0; - } else - metric = ifr.ifr_metric; - printf("The result of SIOCGIFMETRIC is %d\n", metric); - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0) - mtu = 0; - else - mtu = ifr.ifr_mtu; - printf("The result of SIOCGIFMTU is %d\n", mtu); - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFDSTADDR, &ifr) < 0) { - memset(&dstaddr, 0, sizeof(struct sockaddr)); - } else - dstaddr = ifr.ifr_dstaddr; - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFBRDADDR, &ifr) < 0) { - memset(&broadaddr, 0, sizeof(struct sockaddr)); - } else - broadaddr = ifr.ifr_broadaddr; - -- strcpy(ifr.ifr_name, ifname); -+ memset(&ifr, 0, sizeof(ifr)); -+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); - if (ioctl(skfd, SIOCGIFNETMASK, &ifr) < 0) { - memset(&netmask, 0, sizeof(struct sockaddr)); - } else --- -2.29.2 - diff --git a/SOURCES/iputils-ifenslave.patch b/SOURCES/iputils-ifenslave.patch deleted file mode 100644 index 662d69d..0000000 --- a/SOURCES/iputils-ifenslave.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- iputils/ifenslave.c.addr 2006-03-29 15:00:24.000000000 +0200 -+++ iputils/ifenslave.c 2006-03-29 15:02:01.000000000 +0200 -@@ -524,8 +524,8 @@ - if (ioctl(skfd, SIOCGIFADDR, &ifr) < 0) - return -1; - printf("The result of SIOCGIFADDR is %2.2x.%2.2x.%2.2x.%2.2x.\n", -- ifr.ifr_addr.sa_data[0], ifr.ifr_addr.sa_data[1], -- ifr.ifr_addr.sa_data[2], ifr.ifr_addr.sa_data[3]); -+ ifr.ifr_addr.sa_data[2], ifr.ifr_addr.sa_data[3], -+ ifr.ifr_addr.sa_data[4], ifr.ifr_addr.sa_data[5]); - - strcpy(ifr.ifr_name, ifname); - if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) diff --git a/SPECS/iputils.spec b/SPECS/iputils.spec index e454f64..eb9dd86 100644 --- a/SPECS/iputils.spec +++ b/SPECS/iputils.spec @@ -3,7 +3,7 @@ Summary: Network monitoring tools including ping Name: iputils Version: 20210202 -Release: 7%{?dist} +Release: 8%{?dist} # some parts are under the original BSD (ping.c) # some are under GPLv2+ (tracepath.c) License: BSD and GPLv2+ @@ -18,9 +18,9 @@ Source3: ninfod.service Source4: bsd.txt Source5: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt -Patch100: iputils-ifenslave.patch -Patch101: iputils-ifenslave-CWE-170.patch -Patch102: iputils-ifenslave-CWE-170-2.patch +Patch100: 100-iputils-ifenslave.patch +Patch101: 101-iputils-ifenslave-CWE-170.patch +Patch102: 102-iputils-ifenslave-CWE-170-2.patch BuildRequires: gcc BuildRequires: meson @@ -61,16 +61,10 @@ cp %{SOURCE4} %{SOURCE5} . %patch102 -p1 %build -%ifarch s390 s390x - export CFLAGS="-fPIE" -%else - export CFLAGS="-fpie" -%endif -export LDFLAGS="-pie -Wl,-z,relro,-z,now" - %meson -DBUILD_TFTPD=false %meson_build -gcc -Wall $RPM_OPT_FLAGS $CFLAGS $RPM_LD_FLAGS $LDFLAGS ifenslave.c -o ifenslave + +gcc $RPM_OPT_FLAGS $CFLAGS $RPM_LD_FLAGS $LDFLAGS ifenslave.c -o ifenslave %install %meson_install @@ -135,6 +129,9 @@ install -cp ifenslave.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/ %attr(644,root,root) %{_mandir}/man8/ninfod.8.gz %changelog +* Fri Nov 25 2022 Jan Macku - 20210202-8 +- Build iputils and ifenslave with correct flags (rhbz#2144509) + * Mon Aug 09 2021 Mohan Boddu - 20210202-7 - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags Related: rhbz#1991688