1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-10-27 20:30:13 -04:00

Don't crash when using /plugins install disconnected

When we are not connected and run `/plugins install` we crash because we
get the account struct to check for the (xmpp) tls setting.
To apply that to the http (etc) connection to download the plugin from a
server.

This got introduced in 3a86b8c29 to fix #1624.

There are several ways to handle this (some described in 1880) in this
patch I took the route that it will use secure connection when we are
nto connected and will only check the tls.trust account setting if we
are connected.

Fix https://github.com/profanity-im/profanity/issues/1880
This commit is contained in:
Michael Vetter 2023-08-28 07:55:29 +02:00
parent 65d62dbf49
commit b88174709f
2 changed files with 8 additions and 2 deletions

View File

@ -134,7 +134,10 @@ http_file_get(void* userdata)
gchar* cert_path = prefs_get_string(PREF_TLS_CERTPATH); gchar* cert_path = prefs_get_string(PREF_TLS_CERTPATH);
gchar* cafile = cafile_get_name(); gchar* cafile = cafile_get_name();
ProfAccount* account = accounts_get_account(session_get_account_name()); ProfAccount* account = accounts_get_account(session_get_account_name());
gboolean insecure = account->tls_policy && strcmp(account->tls_policy, "trust") == 0; gboolean insecure = FALSE;
if (account) {
insecure = account->tls_policy && strcmp(account->tls_policy, "trust") == 0;
}
account_free(account); account_free(account);
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);

View File

@ -186,8 +186,11 @@ http_file_put(void* userdata)
auto_gchar gchar* cert_path = prefs_get_string(PREF_TLS_CERTPATH); auto_gchar gchar* cert_path = prefs_get_string(PREF_TLS_CERTPATH);
gchar* cafile = cafile_get_name(); gchar* cafile = cafile_get_name();
gboolean insecure = FALSE;
ProfAccount* account = accounts_get_account(session_get_account_name()); ProfAccount* account = accounts_get_account(session_get_account_name());
gboolean insecure = account->tls_policy && strcmp(account->tls_policy, "trust") == 0; if (account) {
insecure = account->tls_policy && strcmp(account->tls_policy, "trust") == 0;
}
account_free(account); account_free(account);
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);