fix: CWE-134 format string vulnerability audit

Security:
- Fix CWE-134 in iq.c: user-controlled string passed as format arg

Annotations:
- Add G_GNUC_PRINTF to variadic functions in ui.h and log.h

Compiler flags (configure.ac):
- Add -Wformat -Wformat-nonliteral -Wno-format-zero-length

Format mismatch fixes:
- chatwin.c: Jid* instead of char* for %s
- connection.c: %x -> %lx for long flags
- cmd_funcs.c: %d -> %zu for MB_CUR_MAX/MB_LEN_MAX (size_t)
- cmd_funcs.c: cast gpointer to (char*) for %s
- cmd_defs.c: %d -> %u for g_list_length() (guint)
- iq.c: from_jid->barejid -> from_jid->fulljid
- console.c, mucwin.c, privwin.c, account.c, omemo.c, presence.c:
  gpointer -> (char*) casts for %s

Bug fixes:
- api.c: broken log_warning() calls with extra format arg
- cmd_funcs.c: remove unused arg from cons_show()

Tooling:
- Expand check-cwe134.sh detection patterns
This commit is contained in:
2026-03-03 14:53:18 +03:00
parent 31538580fb
commit 92953099e1
16 changed files with 258 additions and 72 deletions

View File

@@ -303,7 +303,7 @@ chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_cr
assert(chatwin != NULL);
if (message->plain == NULL) {
log_error("chatwin_incoming_msg: Message with no plain field from: %s", message->from_jid);
log_error("chatwin_incoming_msg: Message with no plain field from: %s", message->from_jid->fulljid);
return;
}