mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 21:46:22 +00:00
refactor: optimize hash table iterations and fix security issues #58
- refactor(core): replace g_hash_table_get_keys with g_hash_table_iter_init
* Eliminates temporary GList allocations
* Improves iteration performance
* Affected: connection.c, cmd_defs.c, cmd_funcs.c, omemo.c, gpg.c,
disco.c, form.c, autocompleters.c, capabilities.c, callbacks.c
- fix(xmpp): correct queued_messages loop in connection.c:1031
* Remove incorrect NULL check that prevented message storage
* calloc zeros array, causing loop to skip immediately
* Fixes dropped messages during reconnection with SM enabled
- fix(ui): prevent format string vulnerabilities in cons_show calls
* Replace cons_show(variable) with cons_show("%s", variable)
* Protects against format string attacks if variables contain %
* Updated instances across cmd_funcs.c, connection.c, ox.c,
console.c, core.c
This commit is contained in:
@@ -532,11 +532,13 @@ omemo_set_device_list(const char* const from, GList* device_list)
|
||||
for (device_id = device_list; device_id != NULL; device_id = device_id->next) {
|
||||
GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid->barejid);
|
||||
if (known_identities) {
|
||||
GList* fp = NULL;
|
||||
for (fp = g_hash_table_get_keys(known_identities); fp != NULL; fp = fp->next) {
|
||||
if (device_id->data == g_hash_table_lookup(known_identities, fp->data)) {
|
||||
cons_show("OMEMO: Adding firstusage trust for %s device %d - Fingerprint %s", jid->barejid, device_id->data, omemo_format_fingerprint(fp->data));
|
||||
omemo_trust(jid->barejid, omemo_format_fingerprint(fp->data));
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
g_hash_table_iter_init(&iter, known_identities);
|
||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||
if (device_id->data == value) {
|
||||
cons_show("OMEMO: Adding firstusage trust for %s device %d - Fingerprint %s", jid->barejid, device_id->data, omemo_format_fingerprint(key));
|
||||
omemo_trust(jid->barejid, omemo_format_fingerprint(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user