Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e95e8b5
build: Add -fstack-protector-strong compiler flag
jubalh Feb 26, 2026
606a102
build: Enable _FORTIFY_SOURCE and -Og optimization
jubalh Feb 26, 2026
ec45a19
build: enable -fanalyzer for static analysis
jubalh Feb 26, 2026
f1d4ed4
refactor: Use g_malloc0 instead of calloc in get_random_string()
jubalh Feb 26, 2026
e1fd2a1
refactor: replace calloc with g_new0 for struct allocations
jubalh Feb 26, 2026
8a36ca6
refactor: start to standardize on gchar
jubalh Feb 26, 2026
abffffb
refactor: make Resource use glib functions
jubalh Feb 26, 2026
f98e33b
refactor: make Jid use glib functions
jubalh Feb 26, 2026
caf84ca
refactor: use g_new in message_pubsub_event_handler_add()
jubalh Feb 26, 2026
48205fc
cleanup: Initialize waittime to 0
jubalh Feb 26, 2026
d29fcdb
refactor: Use p_contact_new instead of malloc in p_contact_new()
jubalh Feb 26, 2026
3d2a82a
cleanup: Fix potential NULL dereference in cmd_omemo_(un)trust
jubalh Feb 26, 2026
9f3d78a
refactor: Make _writecsv safer and with better performance
jubalh Feb 26, 2026
5711671
refactor: roster export uses GString and g_file_set_contents now
jubalh Feb 26, 2026
156b78a
cleanup: fix potential NULL dereference and leaks in cmd_sendfile
jubalh Feb 26, 2026
ba5614f
cleanup: use auto_FILE and handle fopen failure in command_docgen
jubalh Feb 26, 2026
4ee3502
cleanup: use g_malloc and auto_gchar in _win_print_wrapped
jubalh Feb 26, 2026
65ca3c4
fix: handle potential NULL from malloc in OMEMO fingerprint decoding
jubalh Feb 26, 2026
aec8e48
refactor: modernize cmd_ac_complete_filepath and simplify path handling
jubalh Feb 26, 2026
55be1de
cleanup: use g_new0 and g_strdup for alias allocation
jubalh Feb 26, 2026
45dc50e
fix: initialize OMEMO pointers and add NULL checks
jubalh Feb 26, 2026
2015404
refactor: Move pgp module to gchar
jubalh Feb 26, 2026
de5949e
refactor: partly move plugins to glib
jubalh Feb 26, 2026
373ec4a
refactor: replace malloc with g_new0 in many occasions
jubalh Feb 26, 2026
d8a7b23
fix: segfault when using /command help
jubalh Feb 27, 2026
f74501e
cleanup: add a defensive check in cmd_process_input()
jubalh Feb 27, 2026
16080ab
cleanup: Fix potential null pointer dereference
jubalh Feb 27, 2026
2406413
fix: fix NULL dereference and memory leaks in OX logic
jubalh Feb 27, 2026
1ec536d
fix: fix api_get_current_occupants() memory problems
jubalh Feb 27, 2026
776bc26
refactor: change vcard_print() checks
jubalh Feb 27, 2026
e15f659
fix: Fix NULL dereference and memory leak in _mam_rsm_id_handler
jubalh Feb 27, 2026
0218ba2
fix: fix memory leak and potential crash in iq_id_handler_add
jubalh Feb 27, 2026
5d31f37
cleanup: check for strdup() success in stanza_create_http_upload_requ…
jubalh Feb 27, 2026
f5787fb
cleanup: refactor account_eval_password to use glib
jubalh Feb 27, 2026
286e563
fix: fix redundant error reporting in http download
jubalh Feb 27, 2026
7b0232c
wleanup: be a bit more defensive in server_events.c
jubalh Feb 27, 2026
7876645
cleanup: be a bit more defensive in
jubalh Feb 27, 2026
35030b7
cleanup: use g_new0 instead of malloc in buffer_get_entry_by_id()
jubalh Feb 27, 2026
10ef850
cleanup: Cleanup log modul
jubalh Feb 27, 2026
051f986
cleanup: make _connection_handler() safer
jubalh Feb 27, 2026
02cde29
cleanup: use g_new() instead of malloc in prof_add_shutdown_routine()
jubalh Feb 27, 2026
36b15ec
tests: update unit tests
jubalh Feb 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ if is_debug
'-Wunused',
'-Wall',
'-Wextra',
'-fstack-protector-strong',
'-D_FORTIFY_SOURCE=2',
'-Og'
], language: 'c')
if cc.get_id() == 'gcc'
add_project_arguments('-fanalyzer', language: 'c')
endif
endif

if cc.get_id() == 'clang'
Expand Down
4 changes: 2 additions & 2 deletions src/chatlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ _create_chatlog(const char* const other, const char* const login)
GDateTime* now = g_date_time_new_now_local();
auto_char char* filename = _get_log_filename(other, login, now, FALSE);

struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log));
struct dated_chat_log* new_log = g_new0(struct dated_chat_log, 1);
new_log->filename = strdup(filename);
new_log->date = now;

Expand All @@ -431,7 +431,7 @@ _create_groupchat_log(const char* const room, const char* const login)
GDateTime* now = g_date_time_new_now_local();
auto_char char* filename = _get_log_filename(room, login, now, TRUE);

struct dated_chat_log* new_log = malloc(sizeof(struct dated_chat_log));
struct dated_chat_log* new_log = g_new0(struct dated_chat_log, 1);
new_log->filename = strdup(filename);
new_log->date = now;

Expand Down
99 changes: 42 additions & 57 deletions src/command/cmd_ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1653,101 +1653,86 @@ cmd_ac_uninit(void)
}

static void
_filepath_item_free(char** ptr)
_filepath_item_free(gchar** ptr)
{
char* item = *ptr;
free(item);
gchar* item = *ptr;
g_free(item);
}

char*
cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous)
{
unsigned int output_off = 0;
char* tmp = NULL;

// strip command
char* inpcp = (char*)input + strlen(startstr);
while (*inpcp == ' ') {
inpcp++;
char* inpcp_ptr = (char*)input + strlen(startstr);
while (*inpcp_ptr == ' ') {
inpcp_ptr++;
}

inpcp = strdup(inpcp);
auto_gchar gchar* inpcp = g_strdup(inpcp_ptr);
if (!inpcp) {
return NULL;
}

// strip quotes
if (*inpcp == '"') {
tmp = strrchr(inpcp + 1, '"');
if (tmp) {
*tmp = '\0';
if (inpcp[0] == '"') {
char* last_quote = strrchr(inpcp + 1, '"');
if (last_quote) {
*last_quote = '\0';
}
tmp = strdup(inpcp + 1);
free(inpcp);
inpcp = tmp;
tmp = NULL;
gchar* unquoted = g_strdup(inpcp + 1);
inpcp = unquoted;
}

// expand ~ to $HOME
if (inpcp[0] == '~' && inpcp[1] == '/') {
char* home = getenv("HOME");
if (!home) {
free(inpcp);
return NULL;
}
tmp = g_strdup_printf("%s/%sfoo", home, inpcp + 2);
output_off = strlen(home) + 1;
} else {
tmp = g_strdup_printf("%sfoo", inpcp);
}
free(inpcp);
if (!tmp) {
auto_gchar gchar* expanded = get_expanded_path(inpcp);
if (!expanded) {
return NULL;
}

char* foofile = strdup(basename(tmp));
char* directory = strdup(dirname(tmp));
g_free(tmp);
auto_gchar gchar* foofile = g_path_get_basename(expanded);
auto_gchar gchar* directory = g_path_get_dirname(expanded);

// If the input ends with a slash, the basename will be "." or "/"
// In that case, we are looking for all files in that directory
gboolean find_all = FALSE;
if (inpcp[strlen(inpcp) - 1] == '/') {
find_all = TRUE;
}

GArray* files = g_array_new(TRUE, FALSE, sizeof(char*));
GArray* files = g_array_new(TRUE, FALSE, sizeof(gchar*));
g_array_set_clear_func(files, (GDestroyNotify)_filepath_item_free);

DIR* d = opendir(directory);
if (d) {
struct dirent* dir;

while ((dir = readdir(d)) != NULL) {
if (strcmp(dir->d_name, ".") == 0) {
if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
continue;
} else if (strcmp(dir->d_name, "..") == 0) {
}

// check if it matches prefix
if (!find_all && !g_str_has_prefix(dir->d_name, foofile)) {
continue;
} else if (*(dir->d_name) == '.' && *foofile != '.') {
// only show hidden files on explicit request
}

// only show hidden files on explicit request
if (dir->d_name[0] == '.' && (find_all || foofile[0] != '.')) {
continue;
}

char* acstring = NULL;
if (output_off) {
tmp = g_strdup_printf("%s/%s", directory, dir->d_name);
if (tmp) {
acstring = g_strdup_printf("~/%s", tmp + output_off);
g_free(tmp);
}
} else if (strcmp(directory, "/") == 0) {
auto_gchar gchar* acstring = NULL;
if (strcmp(directory, "/") == 0) {
acstring = g_strdup_printf("/%s", dir->d_name);
} else {
acstring = g_strdup_printf("%s/%s", directory, dir->d_name);
}
if (!acstring) {
g_array_free(files, TRUE);
free(foofile);
free(directory);
return NULL;
}

g_array_append_val(files, acstring);
if (acstring) {
g_array_append_val(files, acstring);
}
}
closedir(d);
}
free(directory);
free(foofile);

autocomplete_update(filepath_ac, (char**)files->data);
g_array_free(files, TRUE);
Expand Down
12 changes: 8 additions & 4 deletions src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2976,8 +2976,14 @@ command_docgen(void)
cmds = g_list_insert_sorted(cmds, (gpointer)pcmd, (GCompareFunc)_cmp_command);
}

FILE* toc_fragment = fopen("toc_fragment.html", "w");
FILE* main_fragment = fopen("main_fragment.html", "w");
auto_FILE FILE* toc_fragment = fopen("toc_fragment.html", "w");
auto_FILE FILE* main_fragment = fopen("main_fragment.html", "w");

if (!toc_fragment || !main_fragment) {
printf("\nError opening html files: %s.\n", strerror(errno));
g_list_free(cmds);
return;
}

fputs("<ul><li><ul><li>\n", toc_fragment);
fputs("<hr>\n", main_fragment);
Expand Down Expand Up @@ -3045,8 +3051,6 @@ command_docgen(void)

fputs("</ul></ul>\n", toc_fragment);

fclose(toc_fragment);
fclose(main_fragment);
printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
g_list_free(cmds);
}
Expand Down
Loading
Loading