mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-22 07:56:21 +00:00
Security: Fix CWE-134 in iq.c: user-controlled string passed as format argument Add G_GNUC_PRINTF annotations to all variadic printf-like wrappers in ui.h, log.h and http_common.h Compiler flags (configure.ac): Replace basic -Wformat/-Wformat-nonliteral with -Wformat=2 Add -Wextra, -Wnull-dereference, -Wpointer-arith, -Wimplicit-function-declaration, -Wundef, -Wfloat-equal, -Wredundant-decls, -Walloc-zero Add -fstack-protector-strong, -fno-common, -D_FORTIFY_SOURCE=2 Add GCC-specific flags via AC_COMPILE_IFELSE: -Wlogical-op, -Wduplicated-cond, -Wduplicated-branches, -Wstringop-overflow, -Warray-bounds=2 Suppress noisy -Wextra sub-warnings: -Wno-unused-parameter, -Wno-missing-field-initializers, -Wno-sign-compare, -Wno-cast-function-type Remove AM_CFLAGS/CFLAGS duplication Bug fixes found by new warnings: chatlog.c: non-MUCPM redact path passed resourcepart instead of NULL rosterwin.c: merge duplicated if/else branches into single condition omemo.c: redundant else-if in omemo_automatic_start; remove unnecessary scope block and goto, use early return console.c: pointer compared to integer 0 instead of NULL stanza.c: increase pri_str/idle_str buffers from 10 to 12 bytes (INT_MIN = -2147483648 needs 12 bytes including NUL) vcard.c: NULL guard for filename before g_file_set_contents api.c: broken log_warning() calls with extra format argument Format mismatch fixes: chatwin.c: Jid* → char* for %s connection.c: %x → %lx for long flags cmd_funcs.c: %d → %zu for size_t; cast gpointer to char* for %s cmd_defs.c: %d → %u for g_list_length() return (guint) iq.c: barejid → fulljid for from_jid console.c, mucwin.c, privwin.c, account.c, omemo.c, presence.c: gpointer → (char*) casts for %s Const-correctness and cleanup: database.c: const for type, query, sort variables form.c/xmpp.h: const for form_set_value parameter files.c: refactor to early return, eliminating NULL logfile path muc.c/muc.h: remove meaningless top-level const on return type common.c: const for URL string literal Remove stale declarations: cons_show_desktop_prefs (ui.h), connection_set_priority (connection.h), omemo_devicelist_configure_and_request (omemo.h) test_common.c: add currb NULL check to silence -Wnull-dereference Tooling (check-cwe134.sh): Reduce from 5 checks to 2 (checks 1-3 redundant with -Wformat=2) Check 1: verify known wrappers have G_GNUC_PRINTF attribute Check 2: auto-detect unannotated variadic printf-like functions Match both const char* and const gchar* in variadic patterns Author: jabber.developer2 <jabber.developer2@jabber.space>
168 lines
6.3 KiB
C
168 lines
6.3 KiB
C
/*
|
|
* muc.h
|
|
* vim: expandtab:ts=4:sts=4:sw=4
|
|
*
|
|
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
|
*
|
|
* This file is part of Profanity.
|
|
*
|
|
* Profanity is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Profanity is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
* link the code of portions of this program with the OpenSSL library under
|
|
* certain conditions as described in each individual source file, and
|
|
* distribute linked combinations including the two.
|
|
*
|
|
* You must obey the GNU General Public License in all respects for all of the
|
|
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
|
* may extend this exception to your version of the file(s), but you are not
|
|
* obligated to do so. If you do not wish to do so, delete this exception
|
|
* statement from your version. If you delete this exception statement from all
|
|
* source files in the program, then also delete it here.
|
|
*
|
|
*/
|
|
|
|
#ifndef XMPP_MUC_H
|
|
#define XMPP_MUC_H
|
|
|
|
#include <glib.h>
|
|
|
|
#include "tools/autocomplete.h"
|
|
#include "ui/win_types.h"
|
|
#include "xmpp/contact.h"
|
|
#include "xmpp/jid.h"
|
|
|
|
typedef enum {
|
|
MUC_ROLE_NONE,
|
|
MUC_ROLE_VISITOR,
|
|
MUC_ROLE_PARTICIPANT,
|
|
MUC_ROLE_MODERATOR
|
|
} muc_role_t;
|
|
|
|
typedef enum {
|
|
MUC_AFFILIATION_NONE,
|
|
MUC_AFFILIATION_OUTCAST,
|
|
MUC_AFFILIATION_MEMBER,
|
|
MUC_AFFILIATION_ADMIN,
|
|
MUC_AFFILIATION_OWNER
|
|
} muc_affiliation_t;
|
|
|
|
typedef enum {
|
|
MUC_MEMBER_TYPE_UNKNOWN,
|
|
MUC_MEMBER_TYPE_PUBLIC,
|
|
MUC_MEMBER_TYPE_MEMBERS_ONLY
|
|
} muc_member_type_t;
|
|
|
|
typedef enum {
|
|
MUC_ANONYMITY_TYPE_UNKNOWN,
|
|
MUC_ANONYMITY_TYPE_NONANONYMOUS,
|
|
MUC_ANONYMITY_TYPE_SEMIANONYMOUS
|
|
} muc_anonymity_type_t;
|
|
|
|
typedef struct _muc_occupant_t
|
|
{
|
|
char* nick;
|
|
gchar* nick_collate_key;
|
|
char* jid;
|
|
muc_role_t role;
|
|
muc_affiliation_t affiliation;
|
|
resource_presence_t presence;
|
|
char* status;
|
|
} Occupant;
|
|
|
|
void muc_init(void);
|
|
|
|
void muc_join(const char* const room, const char* const nick, const char* const password, gboolean autojoin);
|
|
void muc_leave(const char* const room);
|
|
|
|
gboolean muc_active(const char* const room);
|
|
gboolean muc_autojoin(const char* const room);
|
|
|
|
GList* muc_rooms(void);
|
|
|
|
void muc_set_features(const char* const room, GSList* features);
|
|
|
|
const char* muc_nick(const char* const room);
|
|
char* muc_password(const char* const room);
|
|
|
|
void muc_nick_change_start(const char* const room, const char* const new_nick);
|
|
void muc_nick_change_complete(const char* const room, const char* const nick);
|
|
gboolean muc_nick_change_pending(const char* const room);
|
|
char* muc_old_nick(const char* const room, const char* const new_nick);
|
|
|
|
gboolean muc_roster_contains_nick(const char* const room, const char* const nick);
|
|
gboolean muc_roster_complete(const char* const room);
|
|
gboolean muc_roster_add(const char* const room, const char* const nick, const char* const jid, const char* const role,
|
|
const char* const affiliation, const char* const show, const char* const status);
|
|
void muc_roster_remove(const char* const room, const char* const nick);
|
|
void muc_roster_set_complete(const char* const room);
|
|
GList* muc_roster(const char* const room);
|
|
Autocomplete muc_roster_ac(const char* const room);
|
|
Autocomplete muc_roster_jid_ac(const char* const room);
|
|
void muc_jid_autocomplete_reset(const char* const room);
|
|
void muc_jid_autocomplete_add_all(const char* const room, GSList* jids);
|
|
|
|
Occupant* muc_roster_item(const char* const room, const char* const nick);
|
|
|
|
gboolean muc_occupant_available(Occupant* occupant);
|
|
const char* muc_occupant_affiliation_str(Occupant* occupant);
|
|
const char* muc_occupant_role_str(Occupant* occupant);
|
|
GSList* muc_occupants_by_role(const char* const room, muc_role_t role);
|
|
GSList* muc_occupants_by_affiliation(const char* const room, muc_affiliation_t affiliation);
|
|
|
|
void muc_occupant_nick_change_start(const char* const room, const char* const new_nick, const char* const old_nick);
|
|
char* muc_roster_nick_change_complete(const char* const room, const char* const nick);
|
|
|
|
void muc_confserver_add(const char* const server);
|
|
void muc_confserver_reset_ac(void);
|
|
char* muc_confserver_find(const char* const search_str, gboolean previous, void* context);
|
|
void muc_confserver_clear(void);
|
|
|
|
void muc_invites_add(const char* const room, const char* const password);
|
|
void muc_invites_remove(const char* const room);
|
|
gint muc_invites_count(void);
|
|
GList* muc_invites(void);
|
|
gboolean muc_invites_contain(const char* const room);
|
|
void muc_invites_reset_ac(void);
|
|
char* muc_invites_find(const char* const search_str, gboolean previous, void* context);
|
|
void muc_invites_clear(void);
|
|
char* muc_invite_password(const char* const room);
|
|
|
|
void muc_set_subject(const char* const room, const char* const subject);
|
|
char* muc_subject(const char* const room);
|
|
|
|
void muc_pending_broadcasts_add(const char* const room, const char* const message);
|
|
GList* muc_pending_broadcasts(const char* const room);
|
|
|
|
char* muc_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
|
void muc_autocomplete_reset(const char* const room);
|
|
|
|
gboolean muc_requires_config(const char* const room);
|
|
void muc_set_requires_config(const char* const room, gboolean val);
|
|
|
|
void muc_set_role(const char* const room, const char* const role);
|
|
void muc_set_affiliation(const char* const room, const char* const affiliation);
|
|
char* muc_role_str(const char* const room);
|
|
char* muc_affiliation_str(const char* const room);
|
|
|
|
muc_member_type_t muc_member_type(const char* const room);
|
|
muc_anonymity_type_t muc_anonymity_type(const char* const room);
|
|
|
|
GList* muc_members(const char* const room);
|
|
void muc_members_add(const char* const room, const char* const jid);
|
|
void muc_members_remove(const char* const room, const char* const jid);
|
|
void muc_members_update(const char* const room, const char* const jid, const char* const affiliation);
|
|
|
|
#endif
|