diff --git a/0001-Fix-GCC-12-warning.patch b/0001-Fix-GCC-12-warning.patch new file mode 100644 index 0000000000000000000000000000000000000000..c22567d44e37e90270f69080cf57057bb3e2099f --- /dev/null +++ b/0001-Fix-GCC-12-warning.patch @@ -0,0 +1,38 @@ +From f6401524e1be537a78b24aef686968e2b9af7493 Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Thu, 27 Jan 2022 14:36:01 +0100 +Subject: [PATCH] Fix GCC 12 warning. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes: + inlined from ‘show_full_lun_info’ at fcoeadm_display.c:310:2: +/usr/include/bits/stdio2.h:112:10: error: ‘osname’ may be used uninitialized [-Werror=maybe-uninitialized] + 112 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +fcoeadm_display.c: In function ‘show_full_lun_info’: +fcoeadm_display.c:249:15: note: ‘osname’ was declared here + 249 | char *osname; + | ^~~~~~ +reference: https://github.com/morbidrsa/fcoe-utils/commit/f6401524e1be537a78b24aef686968e2b9af7493 +--- + fcoeadm_display.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fcoeadm_display.c b/fcoeadm_display.c +index c2ef33b82cf..3a18138eefd 100644 +--- a/fcoeadm_display.c ++++ b/fcoeadm_display.c +@@ -246,7 +246,7 @@ static void show_full_lun_info(unsigned int hba, unsigned int port, + char vendor[256]; + char model[256]; + char rev[256]; +- char *osname; ++ char *osname = NULL; + char *capstr; + uint64_t lba = 0; + uint32_t blksize = 0; +-- +2.39.1 + diff --git a/0001-Fix-two-gcc-11-compiler-warnings.patch b/0001-Fix-two-gcc-11-compiler-warnings.patch new file mode 100644 index 0000000000000000000000000000000000000000..be197347a164de436b7c5fc396ed83dbfc9949d9 --- /dev/null +++ b/0001-Fix-two-gcc-11-compiler-warnings.patch @@ -0,0 +1,69 @@ +From 66616e988778c45a316d6b286fda732843f25297 Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Mon, 22 Mar 2021 18:28:33 -0700 +Subject: [PATCH] Fix two gcc-11 compiler warnings. + +Gcc-11 is aggressive about gaurding against array copies. So be +clear about what we want to copy, and where we are copying it. + +Changes from V1: +* simplified both cases based on review comments +* no need to copy the data twice + +reference: https://github.com/morbidrsa/fcoe-utils/commit/66616e988778c45a316d6b286fda732843f25297 +--- + fcping.c | 8 ++++++-- + fipvlan.c | 11 +++++++++-- + 2 files changed, 15 insertions(+), 4 deletions(-) + +diff --git a/fcping.c b/fcping.c +index bf2bc0f0c78..21830a52524 100644 +--- a/fcping.c ++++ b/fcping.c +@@ -570,6 +570,7 @@ fp_ns_get_id(uint32_t op, fc_wwn_t wwn, char *response, size_t *resp_len) + struct sg_io_v4 sg_io; + size_t actual_len; + int cmd, rc = 0; ++ uint32_t *uct = (uint32_t *)&ct.hdr; + + memset((char *)&cdb, 0, sizeof(cdb)); + memset(&ct, 0, sizeof(ct)); +@@ -584,8 +585,11 @@ fp_ns_get_id(uint32_t op, fc_wwn_t wwn, char *response, size_t *resp_len) + + cdb.msgcode = FC_BSG_HST_CT; + hton24(cdb.rqst_data.h_ct.port_id, 0xfffffc); +- memcpy(&cdb.rqst_data.h_ct.preamble_word0, &ct.hdr, +- 3 * sizeof(uint32_t)); ++ ++ /* copy preamble words one at a time, to make compiler happy */ ++ cdb.rqst_data.h_ct.preamble_word0 = uct[0]; ++ cdb.rqst_data.h_ct.preamble_word1 = uct[1]; ++ cdb.rqst_data.h_ct.preamble_word2 = uct[2]; + + sg_io.guard = 'Q'; + sg_io.protocol = BSG_PROTOCOL_SCSI; +diff --git a/fipvlan.c b/fipvlan.c +index c8a07339314..4433c0abf76 100644 +--- a/fipvlan.c ++++ b/fipvlan.c +@@ -447,8 +447,15 @@ static void rtnl_recv_newlink(struct nlmsghdr *nh) + iff->iflink = *(int *)RTA_DATA(ifla[IFLA_LINK]); + 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); ++ ++ /* ++ * copy MAC address and interface name using intermediate ++ * arrays, so gcc-11 knows we are not overflowing buffers ++ */ ++ if (ifla[IFLA_ADDRESS]) ++ memcpy(iff->mac_addr, RTA_DATA(ifla[IFLA_ADDRESS]), ETHER_ADDR_LEN); ++ if (ifla[IFLA_IFNAME]) ++ memcpy(iff->ifname, RTA_DATA(ifla[IFLA_IFNAME]), IFNAMSIZ); + iff->ifname[IFNAMSIZ - 1] = '\0'; + + if (ifla[IFLA_LINKINFO]) { +-- +2.39.1 + diff --git a/0001-fcoemon-add-snprintf-string-precision-modifiers-in-f.patch b/0001-fcoemon-add-snprintf-string-precision-modifiers-in-f.patch new file mode 100644 index 0000000000000000000000000000000000000000..7430a81d7da86d2ab1ab779ac50e67ebe50d55cb --- /dev/null +++ b/0001-fcoemon-add-snprintf-string-precision-modifiers-in-f.patch @@ -0,0 +1,97 @@ +From c54147b3ada8c37a536a4df90e8707538021ed20 Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Fri, 4 Feb 2022 09:21:47 -0800 +Subject: [PATCH] fcoemon: add snprintf string precision modifiers in + fcm_netif_advance + +GCC 12 is warning of potential snprintf truncations + +fcm_netif.ifname is an IFNAMSIZ array, but formating with %s doesn't +understand that, so add a precision modifier every time we print it to +limit the output. This allows the compiler to verify that the output +buffer is of sufficient length to never truncate. + +Signed-off-by: Chris Leech + +reference: https://github.com/morbidrsa/fcoe-utils/commit/c54147b3ada8c37a536a4df90e8707538021ed20 +--- + fcoemon.c | 28 ++++++++++++++-------------- + 1 file changed, 14 insertions(+), 14 deletions(-) + +diff --git a/fcoemon.c b/fcoemon.c +index 8c08bc5a032..b85f276c7df 100644 +--- a/fcoemon.c ++++ b/fcoemon.c +@@ -3135,55 +3135,55 @@ static void fcm_netif_advance(struct fcm_netif *ff) + case FCD_ERROR: + break; + case FCD_GET_DCB_STATE: +- snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s", ++ snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%.*s", + DCB_CMD, CLIF_RSP_VERSION, + CMD_GET_CONFIG, FEATURE_DCB, 0, +- (u_int) strlen(ff->ifname), ff->ifname); ++ (u_int) strlen(ff->ifname), IFNAMSIZ, ff->ifname); + ff->response_pending = fcm_dcbd_request(buf); + break; + case FCD_SEND_CONF: + snprintf(params, sizeof(params), "%x1%x02", + ff->ff_app_info.enable, + ff->ff_app_info.willing); +- snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s", ++ snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%.*s%s", + DCB_CMD, CLIF_RSP_VERSION, + CMD_SET_CONFIG, FEATURE_APP, APP_FCOE_STYPE, +- (u_int) strlen(ff->ifname), ff->ifname, params); ++ (u_int) strlen(ff->ifname), IFNAMSIZ, ff->ifname, params); + ff->response_pending = fcm_dcbd_request(buf); + break; + case FCD_GET_PFC_CONFIG: +- snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s", ++ snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%.*s%s", + DCB_CMD, CLIF_RSP_VERSION, + CMD_GET_CONFIG, FEATURE_PFC, 0, +- (u_int) strlen(ff->ifname), ff->ifname, ""); ++ (u_int) strlen(ff->ifname), IFNAMSIZ, ff->ifname, ""); + ff->response_pending = fcm_dcbd_request(buf); + break; + case FCD_GET_APP_CONFIG: +- snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s", ++ snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%.*s%s", + DCB_CMD, CLIF_RSP_VERSION, + CMD_GET_CONFIG, FEATURE_APP, APP_FCOE_STYPE, +- (u_int) strlen(ff->ifname), ff->ifname, ""); ++ (u_int) strlen(ff->ifname), IFNAMSIZ, ff->ifname, ""); + ff->response_pending = fcm_dcbd_request(buf); + break; + case FCD_GET_PFC_OPER: +- snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s", ++ snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%.*s%s", + DCB_CMD, CLIF_RSP_VERSION, + CMD_GET_OPER, FEATURE_PFC, 0, +- (u_int) strlen(ff->ifname), ff->ifname, ""); ++ (u_int) strlen(ff->ifname), IFNAMSIZ, ff->ifname, ""); + ff->response_pending = fcm_dcbd_request(buf); + break; + case FCD_GET_APP_OPER: +- snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s", ++ snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%.*s%s", + DCB_CMD, CLIF_RSP_VERSION, + CMD_GET_OPER, FEATURE_APP, APP_FCOE_STYPE, +- (u_int) strlen(ff->ifname), ff->ifname, ""); ++ (u_int) strlen(ff->ifname), IFNAMSIZ, ff->ifname, ""); + ff->response_pending = fcm_dcbd_request(buf); + break; + case FCD_GET_PEER: +- snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s", ++ snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%.*s%s", + DCB_CMD, CLIF_RSP_VERSION, + CMD_GET_PEER, FEATURE_APP, APP_FCOE_STYPE, +- (u_int) strlen(ff->ifname), ff->ifname, ""); ++ (u_int) strlen(ff->ifname), IFNAMSIZ, ff->ifname, ""); + ff->response_pending = fcm_dcbd_request(buf); + break; + case FCD_DONE: +-- +2.39.1 + diff --git a/fcoe-utils.spec b/fcoe-utils.spec index 30fb40976542755c1badb91c7133dcba3ffede68..893eb4b768257fdb4fbdc0bb49b1c22fd21fe7c9 100644 --- a/fcoe-utils.spec +++ b/fcoe-utils.spec @@ -1,6 +1,6 @@ Name: fcoe-utils Version: 1.0.33 -Release: 3 +Release: 4 Summary: Fibre Channel over Ethernet utilities License: GPLv2 URL: https://github.com/morbidrsa/fcoe-utils @@ -12,6 +12,9 @@ Patch2: backport-02-string_op_truncation_format_trauncation.patch Patch3: backport-03-use-of-uninitialized-values-detected-during-LTO.patch #This patch refer to ubuntu's version Patch4: backport-Fix-build-error-to-change-char-type.patch +Patch5: 0001-Fix-two-gcc-11-compiler-warnings.patch +Patch6: 0001-Fix-GCC-12-warning.patch +Patch7: 0001-fcoemon-add-snprintf-string-precision-modifiers-in-f.patch BuildRequires: autoconf automake libpciaccess-devel libtool lldpad-devel systemd Requires: lldpad iproute device-mapper-multipath @@ -67,7 +70,10 @@ done %{_mandir}/man8/* %changelog -* Wed Mar 03 2022 xu_ping - 1.0.33-3 +* Fri Jul 14 2023 chenchen - 1.0.33-4 +- fix build error caused by upgrading gcc to 12.3.0 + +* Thu Mar 03 2022 xu_ping - 1.0.33-3 - Backport upstream patch to avoid non-X86 build break. * Wed Aug 2021 sunguoshuai - 1.0.33-2