[Openvpn-devel] netcfg-dco: fix ignoring return value of ParseFromString key_config

Message ID 20260402221251.16811-2-Alesha72003@ya.ru
State New
Headers show
Series [Openvpn-devel] netcfg-dco: fix ignoring return value of ParseFromString key_config | expand

Commit Message

Alexey Slokva April 2, 2026, 10:09 p.m. UTC
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.

Signed-off-by: Alexey Slokva <Alesha72003@ya.ru>
---
 src/netcfg/netcfg-dco.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/src/netcfg/netcfg-dco.cpp b/src/netcfg/netcfg-dco.cpp
index 290c12a8..c39c741f 100644
--- a/src/netcfg/netcfg-dco.cpp
+++ b/src/netcfg/netcfg-dco.cpp
@@ -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)
     {