From: Georgi Valkov Date: Mon, 27 May 2024 14:30:54 +0000 (+0300) Subject: frr: fix compilation with GCC14 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=4ef2b7e0fc3d0cb714e7522b8c9fc57185681560;p=feed%2Fpackages.git frr: fix compilation with GCC14 Fixes: zebra/zebra_netns_notify.c: In function 'zebra_ns_ready_read': zebra/zebra_netns_notify.c:265:40: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration] 265 | if (strmatch(VRF_DEFAULT_NAME, basename(netnspath))) { | ^~~~~~~~ Fixed by including libgen.h, then since basename may modify its parameter, allocate a copy on the stack, using strdupa, and pass the temporary string to basename. According to the man page for basename: With glibc, one gets the POSIX version of basename() when is included, and the GNU version otherwise. The POSIX version of basename may modify the contents of path, so we should to pass a copy when calling this function. [1] https://man7.org/linux/man-pages/man3/basename.3.html Signed-off-by: Georgi Valkov --- diff --git a/net/frr/Makefile b/net/frr/Makefile index 14249fe618..41ae44bc12 100644 --- a/net/frr/Makefile +++ b/net/frr/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=frr PKG_VERSION:=9.0.0 -PKG_RELEASE:=6 +PKG_RELEASE:=7 PKG_SOURCE_DATE:=2023-08-12 PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_DATE).tar.gz diff --git a/net/frr/patches/900-gcc-14-compatibility.patch b/net/frr/patches/900-gcc-14-compatibility.patch new file mode 100644 index 0000000000..789402a732 --- /dev/null +++ b/net/frr/patches/900-gcc-14-compatibility.patch @@ -0,0 +1,83 @@ +From d286461971735a0b81a53039f38f66c47c632196 Mon Sep 17 00:00:00 2001 +From: Georgi Valkov +Date: Mon, 27 May 2024 17:30:54 +0300 +Subject: [PATCH] zebra: fix compilation with GCC14 + +Fixes: +zebra/zebra_netns_notify.c: In function 'zebra_ns_ready_read': +zebra/zebra_netns_notify.c:265:40: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration] + 265 | if (strmatch(VRF_DEFAULT_NAME, basename(netnspath))) { + | ^~~~~~~~ + +Fixed by including libgen.h, then since basename may modify its +parameter, allocate a copy on the stack, using strdupa, and pass the +temporary string to basename. + +According to the man page for basename: +With glibc, one gets the POSIX version of basename() when + is included, and the GNU version otherwise. + +The POSIX version of basename may modify the contents of path, +so we should to pass a copy when calling this function. + +[1] https://man7.org/linux/man-pages/man3/basename.3.html + +Signed-off-by: Georgi Valkov +--- +--- a/zebra/zebra_netns_notify.c ++++ b/zebra/zebra_netns_notify.c +@@ -14,6 +14,7 @@ + #include + #endif + #include ++#include + #include + #include + +@@ -233,6 +234,7 @@ static void zebra_ns_ready_read(struct e + { + struct zebra_netns_info *zns_info = EVENT_ARG(t); + const char *netnspath; ++ const char *netnspath_basename; + int err, stop_retry = 0; + + if (!zns_info) +@@ -260,23 +262,24 @@ static void zebra_ns_ready_read(struct e + zebra_ns_continue_read(zns_info, stop_retry); + return; + } ++ netnspath_basename = basename(strdupa(netnspath)); + + /* check default name is not already set */ +- if (strmatch(VRF_DEFAULT_NAME, basename(netnspath))) { +- zlog_warn("NS notify : NS %s is already default VRF.Cancel VRF Creation", basename(netnspath)); ++ if (strmatch(VRF_DEFAULT_NAME, netnspath_basename)) { ++ zlog_warn("NS notify : NS %s is already default VRF.Cancel VRF Creation", netnspath_basename); + zebra_ns_continue_read(zns_info, 1); + return; + } +- if (zebra_ns_notify_is_default_netns(basename(netnspath))) { ++ if (zebra_ns_notify_is_default_netns(netnspath_basename)) { + zlog_warn( + "NS notify : NS %s is default VRF. Ignore VRF creation", +- basename(netnspath)); ++ netnspath_basename); + zebra_ns_continue_read(zns_info, 1); + return; + } + + /* success : close fd and create zns context */ +- zebra_ns_notify_create_context_from_entry_name(basename(netnspath)); ++ zebra_ns_notify_create_context_from_entry_name(netnspath_basename); + zebra_ns_continue_read(zns_info, 1); + } + +@@ -395,7 +398,7 @@ void zebra_ns_notify_parse(void) + continue; + } + /* check default name is not already set */ +- if (strmatch(VRF_DEFAULT_NAME, basename(dent->d_name))) { ++ if (strmatch(VRF_DEFAULT_NAME, basename(strdupa(dent->d_name)))) { + zlog_warn("NS notify : NS %s is already default VRF.Cancel VRF Creation", dent->d_name); + continue; + }