fix: address issue #112 follow-ups (OTR strip, presence UAF, OMEMO load)
All checks were successful
CI Code / Check coding style (pull_request) Successful in 33s
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m46s
CI Code / Linux (arch) (pull_request) Successful in 5m36s
CI Code / Linux (debian) (pull_request) Successful in 6m49s
CI Code / Code Coverage (pull_request) Successful in 6m57s

- otr: strip the OTR whitespace tag by shifting the full remaining tail
  (including the trailing NUL) instead of tag_length bytes, which duplicated
  the body for messages longer than the tag (#8).
- xmpp: snapshot resource name/status/priority/presence before
  connection_add_available_resource() transfers ownership of the Resource, so
  the later reads can no longer become a use-after-free (#9).
- omemo: propagate _omemo_finalize_identity_load failure on connect — mark the
  context unloaded, log it, surface a cons_show_error, and stop instead of
  silently leaving OMEMO unavailable (#10).

Refs #112
This commit is contained in:
2026-05-27 14:28:20 +03:00
parent 72f4f186da
commit 77cc33eedd
3 changed files with 25 additions and 9 deletions

View File

@@ -278,7 +278,10 @@ otr_on_message_recv(const char* const barejid, const char* const resource, const
if (strstr(message, OTRL_MESSAGE_TAG_V2) && strstr(message, OTRL_MESSAGE_TAG_V1)) {
tag_length = 32;
}
memmove(whitespace_base, whitespace_base + tag_length, tag_length);
// Shift the remainder of the message (including the trailing NUL)
// left over the tag, not just the next tag_length bytes — otherwise
// the tail is left in place and the body is duplicated/truncated.
memmove(whitespace_base, whitespace_base + tag_length, strlen(whitespace_base + tag_length) + 1);
char* otr_query_message = otr_start_query();
cons_show("OTR Whitespace pattern detected. Attempting to start OTR session…");
free(message_send_chat_otr(barejid, otr_query_message, FALSE, NULL));