From 638b15c6d9d525418638b469b0045230385e59bf Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 21 May 2023 10:57:59 +0200 Subject: [PATCH 1/3] Fix memleak introduced in 5d3c8ce7c164f74f606ff06d1adf849821591a51 Signed-off-by: Steffen Jaeckel --- src/xmpp/iq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index eb72178d..41a2e89d 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1615,6 +1615,7 @@ _version_get_handler(xmpp_stanza_t* const stanza) const char* from = xmpp_stanza_get_from(stanza); ProfAccount* account = accounts_get_account(session_get_account_name()); auto_char char* client = account->client != NULL ? strdup(account->client) : NULL; + account_free(account); bool is_custom_client = client != NULL; gchar* custom_version_str = NULL; if (is_custom_client) { From c0861eed495e52c5db0b7595b83f2bd4e0585222 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 21 May 2023 11:00:32 +0200 Subject: [PATCH 2/3] Improve debug logging Tell the user that a MAM request will be issued delayed instead of showing a warning that MAM isn't supported by the server. Signed-off-by: Steffen Jaeckel --- src/xmpp/iq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 41a2e89d..a9285425 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2728,9 +2728,11 @@ iq_mam_request(ProfChatWin* win, GDateTime* enddate) if (!received_disco_items) { LateDeliveryUserdata* cur_del_data = malloc(sizeof(LateDeliveryUserdata)); cur_del_data->win = win; - cur_del_data->enddate = g_date_time_ref(enddate); - cur_del_data->startdate = g_date_time_ref(startdate); + cur_del_data->enddate = enddate; + cur_del_data->startdate = startdate; late_delivery_windows = g_slist_append(late_delivery_windows, cur_del_data); + log_debug("Save MAM request of %s for later", win->barejid); + return; } _iq_mam_request(win, startdate, enddate); From b6bb50ceb28250317351fd5115e3f187f0c56fba Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 21 May 2023 11:02:14 +0200 Subject: [PATCH 3/3] Fix use-after-free introduced in 8d3c1f79ac7cc2b0830f0afed48dc1fb9008ab0e This fixes #1852 Signed-off-by: Steffen Jaeckel --- src/xmpp/iq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index a9285425..f56e78e6 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2796,7 +2796,9 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata) xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, data->barejid, data->start_datestr, NULL, firstid, NULL); free(firstid); - iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, (ProfIqFreeCallback)_mam_userdata_free, data); + MamRsmUserdata* ndata = malloc(sizeof(*ndata)); + *ndata = *data; + iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, (ProfIqFreeCallback)_mam_userdata_free, ndata); iq_send_stanza(iq); xmpp_stanza_release(iq);