From 54b895428dfe50c461de634fe3d3d2a2f01b2974 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Thu, 19 Jan 2023 13:14:13 -0500 Subject: [PATCH] Do not use assert as it can terminate LogonUI in PLAP use - assert while on login screen is hard to get out of. Only one of these occurrences is relevant for PLAP, but not using assert at all looks a safer option. Signed-off-by: Selva Nair --- openvpn_config.c | 7 +++++-- pkcs11.c | 1 - tray.c | 13 ++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/openvpn_config.c b/openvpn_config.c index 510a2f2..e34401b 100644 --- a/openvpn_config.c +++ b/openvpn_config.c @@ -26,7 +26,6 @@ #endif #include -#include #include "main.h" #include "openvpn-gui-res.h" @@ -433,7 +432,11 @@ BuildFileList() } /* else these parent groups use their saved values */ - assert (&o.groups[persistent_gp] == PERSISTENT_ROOT_GROUP); /* sanity check */ + if (&o.groups[persistent_gp] != PERSISTENT_ROOT_GROUP) + { + MsgToEventLog(EVENTLOG_ERROR_TYPE, L"%hs:%d Logic error", __func__, __LINE__); + return; + } if (issue_warnings) { diff --git a/pkcs11.c b/pkcs11.c index 7861a0a..7a1d2ac 100644 --- a/pkcs11.c +++ b/pkcs11.c @@ -35,7 +35,6 @@ #include #include #include -#include extern options_t o; static const wchar_t *hfontProp; diff --git a/tray.c b/tray.c index 22b8e0b..bbf8b0a 100644 --- a/tray.c +++ b/tray.c @@ -37,7 +37,6 @@ #include "openvpn-gui-res.h" #include "localization.h" #include "misc.h" -#include "assert.h" /* Popup Menus */ HMENU hMenu; @@ -154,7 +153,11 @@ CreatePopupMenus() * even if num_configs = 0, we want num_groups > 0. * This is guaranteed as the root node is always defined. */ - assert(o.num_groups > 0); + if (o.num_groups <= 0) + { + MsgToEventLog(EVENTLOG_ERROR_TYPE, L"%hs:%d Logic error - no config groups", __func__, __LINE__); + return; + } AllocateConnectionMenu(); @@ -253,7 +256,11 @@ CreatePopupMenus() /* Persistent connections always displayed under a submenu */ parent = PERSISTENT_ROOT_GROUP; } - assert(parent); + if (!parent) + { + MsgToEventLog(EVENTLOG_ERROR_TYPE, L"%hs:%d Logic error - parent = NULL", __func__, __LINE__); + continue; /* ignore this config */ + } /* Add config to the current sub menu */ AppendMenu(parent->menu, MF_POPUP, (UINT_PTR) hMenuConn[c->id], c->config_name);