Skip to contentSkip to conversation

(no subject)

Openvpn-devel New Alexey Slokva 1 participant 2 messages Apr 2

lore
Share & tools
lore
#0 lore raw

Hello,

this patch fixes a build failure in the DCO netcfg path caused by ignoring the return value of ParseFromString() when parsing key_config.

Recent protobuf versions mark ParseFromString() as [[nodiscard]], and with stricter warning settings this now breaks the build on Arch Linux.

The patch checks the return value explicitly and throws NetCfgException if parsing fails.

Regards,
Alexey Slokva

#1 lore raw

PATCH 1/1 netcfg-dco: fix ignoring return value of ParseFromString key_config

Recent protobuf versions mark ParseFromString() as [[nodiscard]], which makes ignoring its return value fail the build with stricter warning settings.

Check the return value when decoding key_config and raise NetCfgException if parsing fails.

---
 src/netcfg/netcfg-dco.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
src/netcfg/netcfg-dco.cpp +4 -1
index 290c12a8..c39c741f 100644
@@ -265,7 +265,10 @@ 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("ParseFromString for key_config failed");
+    }
 
     auto copyKeyDirection = [](const DcoKeyConfig_KeyDirection &src, KoRekey::KeyDirection &dst)
     {
Signature · 1 line
2.53.0