[Openvpn-devel] handle result from DcoKeyConfig_ParseFromString

Message ID mzoefoeqRopySw9np2VgZ1sGVs9t8K_MOTi9xy0z8evXtTPgWY75aoy-XNxqWC14hcuup_X-pBCpZgmV2EoHb8D4xWrlVgEQhlSZLcSKmzI=@azban.net
State New
Headers show
Series [Openvpn-devel] handle result from DcoKeyConfig_ParseFromString | expand

Commit Message

azban March 22, 2026, 7:19 a.m. UTC
This previously warned with unused-result, which fails compilation if you are building with warnings as errors. This checks the result and throws an exception if the parsing fails.

Signed-off-by: azban <me@azban.net>

---
src/netcfg/netcfg-dco.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/src/netcfg/netcfg-dco.cpp b/src/netcfg/netcfg-dco.cpp
index 290c12a8..f41836bf 100644
--- a/src/netcfg/netcfg-dco.cpp
+++ b/src/netcfg/netcfg-dco.cpp
@@ -265,7 +265,9 @@  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 config");
+ }

auto copyKeyDirection = [](const DcoKeyConfig_KeyDirection &src, KoRekey::KeyDirection &dst)
{-- 2.51.2