Merge pull request #2109 from profanity-im/more-fixes

More fixes
This commit is contained in:
Michael Vetter
2026-03-16 10:55:56 +01:00
committed by GitHub
2 changed files with 20 additions and 7 deletions

View File

@@ -612,9 +612,13 @@ omemo_sessions_keyfile(void)
return omemo_ctx.sessions.keyfile;
}
static gboolean omemo_sessions_keyfile_save_disable = FALSE;
void
omemo_sessions_keyfile_save(void)
{
if (omemo_sessions_keyfile_save_disable)
return;
save_keyfile(&omemo_ctx.sessions);
}
@@ -766,6 +770,8 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
unsigned char* key_tag = NULL;
size_t ciphertext_len, tag_len;
omemo_sessions_keyfile_save_disable = TRUE;
ciphertext_len = strlen(message);
ciphertext = malloc(ciphertext_len);
if (!ciphertext) {
@@ -775,8 +781,8 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
tag = gcry_malloc_secure(tag_len);
key_tag = gcry_malloc_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH);
key = gcry_random_bytes_secure(AES128_GCM_KEY_LENGTH, GCRY_VERY_STRONG_RANDOM);
iv = gcry_random_bytes_secure(AES128_GCM_IV_LENGTH, GCRY_VERY_STRONG_RANDOM);
key = gcry_random_bytes_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_IV_LENGTH, GCRY_VERY_STRONG_RANDOM);
iv = key + AES128_GCM_KEY_LENGTH;
res = aes128gcm_encrypt(ciphertext, &ciphertext_len, tag, &tag_len, (const unsigned char* const)message, strlen(message), iv, key);
if (res != 0) {
@@ -983,10 +989,11 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
}
out:
omemo_sessions_keyfile_save_disable = FALSE;
omemo_sessions_keyfile_save();
g_list_free_full(keys, (GDestroyNotify)omemo_key_free);
free(ciphertext);
gcry_free(key);
gcry_free(iv);
gcry_free(tag);
gcry_free(key_tag);

View File

@@ -2668,8 +2668,10 @@ _iq_mam_request(ProfChatWin* win, GDateTime* startdate, GDateTime* enddate)
if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_MAM2);
cons_show_error("Server doesn't support MAM (%s).", XMPP_FEATURE_MAM2);
g_date_time_unref(startdate);
g_date_time_unref(enddate);
if (startdate)
g_date_time_unref(startdate);
if (enddate)
g_date_time_unref(enddate);
return;
}
@@ -2718,8 +2720,12 @@ void
iq_mam_request(ProfChatWin* win, GDateTime* enddate)
{
ProfMessage* last_msg = log_database_get_limits_info(win->barejid, TRUE);
GDateTime* startdate = g_date_time_ref(last_msg->timestamp);
message_free(last_msg);
GDateTime* startdate = NULL;
if (last_msg) {
if (last_msg->timestamp)
startdate = g_date_time_ref(last_msg->timestamp);
message_free(last_msg);
}
// Save request for later if disco items haven't been received yet
if (!received_disco_items) {