Skip to content

Commit

Permalink
client: Don't provide statistics if vpnclient object is unavailable
Browse files Browse the repository at this point in the history
Querying the statistics object too early before the vpnclient object has
been started (can happen in 2FA situations) will cause the client
process to segfault as vpnclient is nullptr.

Signed-off-by: David Sommerseth <davids@openvpn.net>
  • Loading branch information
dsommers committed Feb 7, 2020
1 parent c08cf29 commit 004a050
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/client/openvpn3-service-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,13 @@ class BackendClientObject : public DBusObject,
// Returns an array of a string (description) and an int64
// containing the statistics value.
GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE("a{sx}"));
for (auto& sd : vpnclient->GetStats())
if (vpnclient)
{
g_variant_builder_add (b, "{sx}",
sd.key.c_str(), sd.value);
for (auto& sd : vpnclient->GetStats())
{
g_variant_builder_add (b, "{sx}",
sd.key.c_str(), sd.value);
}
}
GVariant *ret = g_variant_builder_end(b);
g_variant_builder_unref(b);
Expand Down

0 comments on commit 004a050

Please sign in to comment.