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 0000000..1c9e3b3 --- /dev/null +++ b/0001-fcoemon-add-snprintf-string-precision-modifiers-in-f.patch @@ -0,0 +1,95 @@ +From c54147b3ada8c37a536a4df90e8707538021ed20 Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Fri, 4 Feb 2022 09:21:47 -0800 +Subject: [PATCH 1/1] 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 +--- + 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.34.1 + diff --git a/fcoe-utils.spec b/fcoe-utils.spec index 8ee8b2a..a32d047 100644 --- a/fcoe-utils.spec +++ b/fcoe-utils.spec @@ -7,7 +7,7 @@ Name: fcoe-utils Version: 1.0.34 -Release: 1.git%{shortcommit0}%{?dist} +Release: 2.git%{shortcommit0}%{?dist} Summary: Fibre Channel over Ethernet utilities License: GPLv2 URL: http://www.open-fcoe.org @@ -27,6 +27,8 @@ Requires(post): systemd Requires(preun): systemd Requires(postun): systemd +Patch1: 0001-fcoemon-add-snprintf-string-precision-modifiers-in-f.patch + %description Fibre Channel over Ethernet utilities fcoeadm - command line tool for configuring FCoE interfaces @@ -78,6 +80,9 @@ done %{_libexecdir}/fcoe/ %changelog +* Fri Feb 04 2022 Chris Leech - 1.0.34-2.gitb233050 +- FTBFS: more gcc 12 snprintf truncation issues on 32-bit arch + * Fri Jan 28 2022 Chris Leech - 1.0.34-1.gitb233050 - FTBFS: update with gcc 12 fix from upstream