[FIX] Fix use-after-free on DMs

This commit is contained in:
LDA 2024-06-29 14:54:39 +02:00
commit 4bcf1db4ec
3 changed files with 10 additions and 3 deletions

View file

@ -13,7 +13,8 @@ For future XEPs:
Informations on what a user is listening to. Matrix doesn't have Informations on what a user is listening to. Matrix doesn't have
good support for status, to be frank. Clients (including KappaChat) good support for status, to be frank. Clients (including KappaChat)
should consider having more support for those, rather than it being should consider having more support for those, rather than it being
stuck as a FluffyChat/Nheko feature for the good of the entire federation. stuck as a FluffyChat/Nheko feature for the good of the entire
federation.
As such, if _any_ client devs hear this, please consider adding these, As such, if _any_ client devs hear this, please consider adding these,
(especially if you're a smElement employee!) (especially if you're a smElement employee!)

View file

@ -143,11 +143,11 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
ref = DbLock(data->db, 3, "rooms", id, "data"); ref = DbLock(data->db, 3, "rooms", id, "data");
json = DbJson(ref); json = DbJson(ref);
direct = JsonValueAsBoolean(HashMapGet(json, "is_direct")); direct = JsonValueAsBoolean(HashMapGet(json, "is_direct"));
DbUnlock(data->db, ref);
if (ParseeIsPuppet(data->config, sender) || if (ParseeIsPuppet(data->config, sender) ||
ParseeManageBan(data, sender, id)) ParseeManageBan(data, sender, id))
{ {
DbUnlock(data->db, ref);
Free(chat_id); Free(chat_id);
Free(reply_id); Free(reply_id);
Free(xepd); Free(xepd);
@ -158,6 +158,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
{ {
ParseeBotHandler(data, event); ParseeBotHandler(data, event);
DbUnlock(data->db, ref);
Free(chat_id); Free(chat_id);
Free(reply_id); Free(reply_id);
Free(xepd); Free(xepd);
@ -172,6 +173,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
XMPPSendPlain(jabber, local, user, body, NULL, NULL, NULL, ev_id, NULL); XMPPSendPlain(jabber, local, user, body, NULL, NULL, NULL, ev_id, NULL);
DbUnlock(data->db, ref);
Free(chat_id); Free(chat_id);
Free(local); Free(local);
Free(reply_id); Free(reply_id);
@ -179,6 +181,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
return; return;
} }
DbUnlock(data->db, ref);
/* Try to find the chat ID */ /* Try to find the chat ID */
muc_id = ParseeGetMUCID(data, chat_id); muc_id = ParseeGetMUCID(data, chat_id);
if (!chat_id) if (!chat_id)

View file

@ -39,7 +39,10 @@ RouteHead(RouteMedia, arr, argp)
HttpResponseHeader(args->ctx, key, val); HttpResponseHeader(args->ctx, key, val);
} }
HttpSendHeaders(args->ctx); HttpSendHeaders(args->ctx);
if (HttpRequestMethodGet(args->ctx) != HTTP_HEAD)
{
StreamCopy(HttpClientStream(cctx), HttpServerStream(args->ctx)); StreamCopy(HttpClientStream(cctx), HttpServerStream(args->ctx));
}
HttpClientContextFree(cctx); HttpClientContextFree(cctx);
Free(server); Free(server);