[PATCH] netcfg: handle ParseFromS tring result for protobuf 34 (nodiscard)
Дмитрий Романов via Openvpn-devel <[email protected]>
| Newsgroups | gmane.network.openvpn.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Building openvpn3-linux v26 with protobuf 34.x and GCC 15 fails in netcfg-dco.cpp: google::protobuf::MessageLite::ParseFromString is now [[nodiscard]], and the project builds with -Werror, so ignoring the return value becomes a hard error (-Werror=unused-result). Check the return value and throw NetCfgException on parse failure, consistent with other error handling in this file. This should fix distributions that already ship protobuf 34 (e.g. Arch). If there is an existing issue on Codeberg for this (e.g. related to nodiscard / protobuf 34), please link this patch there. Signed-off-by: Dmitriy Romanov <[email protected]> DR _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
patch.diff
(text/x-diff, 647 B)
diff --git a/src/netcfg/netcfg-dco.cpp b/src/netcfg/netcfg-dco.cpp
index 0000000..0000000 100644
--- a/src/netcfg/netcfg-dco.cpp
+++ b/src/netcfg/netcfg-dco.cpp
@@ -264,7 +264,11 @@ void NetCfgDCO::method_new_key(GVariant *params)
std::string key_config = glib2::Value::Extract<std::string>(params, 1);
DcoKeyConfig dco_kc;
- dco_kc.ParseFromString(base64->decode(key_config));
+ if (!dco_kc.ParseFromString(base64->decode(key_config)))
+ {
+ throw NetCfgException("Failed to parse DCO key configuration");
+ }
auto copyKeyDirection = [](const DcoKeyConfig_KeyDirection &src, KoRekey::KeyDirection &dst)
{