mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge pull request #1150 from paulfariello/hotfix/omemo-memleaks
Hotfix/omemo memleaks Regards https://github.com/profanity-im/profanity/issues/1131
This commit is contained in:
commit
ad41959cc6
10
prof.supp
10
prof.supp
@ -1176,3 +1176,13 @@
|
|||||||
fun:SHA1_Update
|
fun:SHA1_Update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# gcrypt initialization
|
||||||
|
{
|
||||||
|
gcry_rngcsprng_randomize
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:malloc
|
||||||
|
...
|
||||||
|
fun:omemo_crypto_init
|
||||||
|
...
|
||||||
|
}
|
||||||
|
@ -47,8 +47,19 @@ omemo_crypto_init(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcry_control(GCRYCTL_SUSPEND_SECMEM_WARN);
|
||||||
|
|
||||||
|
gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0);
|
||||||
|
|
||||||
|
gcry_control(GCRYCTL_RESUME_SECMEM_WARN);
|
||||||
|
|
||||||
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
|
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
|
||||||
|
|
||||||
|
/* Ask for a first random buffer to ensure CSPRNG is initialized.
|
||||||
|
* Thus we control the memleak produced by gcrypt initialization and we can
|
||||||
|
* suppress it without having false negatives */
|
||||||
|
gcry_free(gcry_random_bytes_secure(1, GCRY_VERY_STRONG_RANDOM));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1363,14 +1363,14 @@ omemo_automatic_start(const char *const recipient)
|
|||||||
} else if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
|
} else if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROF_OMEMOPOLICY_ALWAYS:
|
case PROF_OMEMOPOLICY_ALWAYS:
|
||||||
if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
|
if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
} else {
|
} else {
|
||||||
return TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,12 @@
|
|||||||
#include "omemo/omemo.h"
|
#include "omemo/omemo.h"
|
||||||
#include "omemo/store.h"
|
#include "omemo/store.h"
|
||||||
|
|
||||||
|
static void _g_hash_table_free(GHashTable *hash_table);
|
||||||
|
|
||||||
GHashTable *
|
GHashTable *
|
||||||
session_store_new(void)
|
session_store_new(void)
|
||||||
{
|
{
|
||||||
return g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
|
return g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_g_hash_table_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
GHashTable *
|
GHashTable *
|
||||||
@ -441,3 +443,10 @@ load_sender_key(signal_buffer **record, signal_buffer **user_record,
|
|||||||
{
|
{
|
||||||
return SG_SUCCESS;
|
return SG_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_g_hash_table_free(GHashTable *hash_table)
|
||||||
|
{
|
||||||
|
g_hash_table_remove_all(hash_table);
|
||||||
|
g_hash_table_unref(hash_table);
|
||||||
|
}
|
||||||
|
@ -290,6 +290,7 @@ connection_send_stanza(const char *const stanza)
|
|||||||
gboolean
|
gboolean
|
||||||
connection_supports(const char *const feature)
|
connection_supports(const char *const feature)
|
||||||
{
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
GList *jids = g_hash_table_get_keys(conn.features_by_jid);
|
GList *jids = g_hash_table_get_keys(conn.features_by_jid);
|
||||||
|
|
||||||
GList *curr = jids;
|
GList *curr = jids;
|
||||||
@ -297,7 +298,8 @@ connection_supports(const char *const feature)
|
|||||||
char *jid = curr->data;
|
char *jid = curr->data;
|
||||||
GHashTable *features = g_hash_table_lookup(conn.features_by_jid, jid);
|
GHashTable *features = g_hash_table_lookup(conn.features_by_jid, jid);
|
||||||
if (features && g_hash_table_lookup(features, feature)) {
|
if (features && g_hash_table_lookup(features, feature)) {
|
||||||
return TRUE;
|
ret = TRUE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
curr = g_list_next(curr);
|
curr = g_list_next(curr);
|
||||||
@ -305,7 +307,7 @@ connection_supports(const char *const feature)
|
|||||||
|
|
||||||
g_list_free(jids);
|
g_list_free(jids);
|
||||||
|
|
||||||
return FALSE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
|
@ -1869,6 +1869,15 @@ stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const iq, co
|
|||||||
|
|
||||||
xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB);
|
xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB);
|
||||||
xmpp_stanza_add_child(pubsub, publish_options);
|
xmpp_stanza_add_child(pubsub, publish_options);
|
||||||
|
|
||||||
|
xmpp_stanza_release(access_model_value_text);
|
||||||
|
xmpp_stanza_release(access_model_value);
|
||||||
|
xmpp_stanza_release(access_model);
|
||||||
|
xmpp_stanza_release(form_type_value_text);
|
||||||
|
xmpp_stanza_release(form_type_value);
|
||||||
|
xmpp_stanza_release(form_type);
|
||||||
|
xmpp_stanza_release(x);
|
||||||
|
xmpp_stanza_release(publish_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user