diff --git a/meta-oe/recipes-security/usbguard/usbguard/0001-PEGTL-fix-demangle-static_assert-with-GCC-16.patch b/meta-oe/recipes-security/usbguard/usbguard/0001-PEGTL-fix-demangle-static_assert-with-GCC-16.patch new file mode 100644 index 0000000000..9538af1b40 --- /dev/null +++ b/meta-oe/recipes-security/usbguard/usbguard/0001-PEGTL-fix-demangle-static_assert-with-GCC-16.patch @@ -0,0 +1,59 @@ +From: Khem Raj +Date: Wed, 25 Jun 2026 00:00:00 +0000 +Subject: [PATCH] PEGTL: fix demangle() static_assert with GCC 16 + +The bundled PEGTL demangles type names at compile time by parsing +__PRETTY_FUNCTION__, which looks like + + ...[with T = X; std::string_view = std::basic_string_view] + +and locating the end of the type name via rfind(';'). + +usbguard instantiates demangle() for PEGTL rules built from +ascii::one<'\000', '\012'> (and friends), i.e. types that carry a char +non-type template parameter whose value is '\0'. GCC 16 renders such a +parameter as a literal NUL byte in __PRETTY_FUNCTION__ and truncates the +generated string at that byte: + + constexpr std::string_view demangle() [with T = seq +--- + src/ThirdParty/PEGTL/include/tao/pegtl/demangle.hpp | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +--- a/src/ThirdParty/PEGTL/include/tao/pegtl/demangle.hpp ++++ b/src/ThirdParty/PEGTL/include/tao/pegtl/demangle.hpp +@@ -114,8 +114,17 @@ + constexpr auto begin = sv.find( '=' ); + static_assert( begin != std::string_view::npos ); + constexpr auto tmp = sv.substr( begin + 2 ); +- constexpr auto end = tmp.rfind( ';' ); +- static_assert( end != std::string_view::npos ); ++ // GCC 16 renders a char non-type template parameter whose value is '\0' ++ // (e.g. PEGTL's ascii::one<'\000', ...>) as a literal NUL byte inside ++ // __PRETTY_FUNCTION__ and truncates the generated string there, dropping ++ // the trailing "; std::string_view = ...]" alias and even the closing ++ // ']'. Fall back to the remainder of the string instead of failing a ++ // static_assert (the demangled name is only used for tracing output). ++ constexpr auto semi = tmp.rfind( ';' ); ++ constexpr auto brak = tmp.rfind( ']' ); ++ constexpr auto end = ( semi != std::string_view::npos ) ? semi ++ : ( brak != std::string_view::npos ) ? brak ++ : tmp.size(); + return tmp.substr( 0, end ); + } diff --git a/meta-oe/recipes-security/usbguard/usbguard_1.1.4.bb b/meta-oe/recipes-security/usbguard/usbguard_1.1.4.bb index 3d181173a5..bed6618fb8 100644 --- a/meta-oe/recipes-security/usbguard/usbguard_1.1.4.bb +++ b/meta-oe/recipes-security/usbguard/usbguard_1.1.4.bb @@ -13,6 +13,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263" SRC_URI = "https://github.com/USBGuard/usbguard/releases/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \ file://0001-Add-and-use-pkgconfig-instead-of-libgcrypt-config.patch \ + file://0001-PEGTL-fix-demangle-static_assert-with-GCC-16.patch \ " SRC_URI[sha256sum] = "7d76b75e779e3c9e6c2fc10e7389dfa34056864c9f0c6eaca722687b7e75893c"