Compare commits

..

1 Commits

Author SHA1 Message Date
bb3b36e162 fix: address config injection and SIGCHLD handling
- Sanitize account names to prevent GKeyFile config injection by
  blocking special characters like #, \n, and \r.
- Ensure GLib's SIGCHLD handler is initialized before forking
  external editors to prevent zombie processes.
- Add missing error check for OMEMO random key generation.
- Replace hardcoded console tab ID with a named constant.
- Log invalid JIDs safely to prevent potential null pointer issues.
2026-05-22 18:27:54 +00:00
4 changed files with 19 additions and 12 deletions

View File

@@ -804,10 +804,6 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
tag_len = AES128_GCM_TAG_LENGTH;
tag = gcry_malloc_secure(tag_len);
key_tag = gcry_malloc_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH);
if (!tag || !key_tag) {
log_error("[OMEMO][SEND] cannot allocate secure buffers");
goto out;
}
key = gcry_random_bytes_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_IV_LENGTH, GCRY_VERY_STRONG_RANDOM);
if (!key) {
@@ -1997,6 +1993,10 @@ _cache_device_identity(const char* const jid, uint32_t device_id, ec_public_key*
g_hash_table_insert(omemo_static_data.fingerprint_ac, strdup(jid), ac);
}
if (!fingerprint) {
return;
}
char* formatted_fingerprint = omemo_format_fingerprint(fingerprint);
if (formatted_fingerprint) {
autocomplete_add(ac, formatted_fingerprint);

View File

@@ -24,6 +24,7 @@
#include "ncurses.h"
#include "ui/ui.h"
#include "xmpp/xmpp.h"
#include "ui/ui.h"
typedef struct EditorContext
{
@@ -120,11 +121,11 @@ launch_editor(gchar* initial_content, void (*callback)(gchar* content, void* dat
ui_suspend();
// Force GLib to install its SIGCHLD handler before forking. Creating a
// GChildWatchSource for our own pid is the documented trigger; we never
// attach or dispatch it, just rely on the side effect.
GSource* sigchld_warmup = g_child_watch_source_new(getpid());
g_source_unref(sigchld_warmup);
// Ensure GLib's SIGCHLD handler is installed before forking to prevent
// zombie children if the editor is launched before the main loop starts.
GMainContext* main_ctx = g_main_context_default();
g_main_context_acquire(main_ctx);
g_main_context_release(main_ctx);
pid_t pid = fork();
if (pid == -1) {

View File

@@ -170,7 +170,12 @@ status_bar_current(guint i)
void
status_bar_inactive(const int win)
{
g_hash_table_remove(statusbar->tabs, GINT_TO_POINTER((win == 0) ? CONSOLE_TAB_ID : win));
int true_win = win;
if (true_win == 0) {
true_win = 10;
}
g_hash_table_remove(statusbar->tabs, GINT_TO_POINTER(true_win));
status_bar_draw();
}
@@ -178,6 +183,8 @@ status_bar_inactive(const int win)
void
_create_tab(const int win, win_type_t wintype, char* identifier, gboolean highlight)
{
int true_win = win == 0 ? 10 : win;
StatusBarTab* tab = g_new0(StatusBarTab, 1);
tab->identifier = strdup(identifier);
tab->highlight = highlight;
@@ -207,7 +214,7 @@ _create_tab(const int win, win_type_t wintype, char* identifier, gboolean highli
}
}
g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER((win == 0) ? CONSOLE_TAB_ID : win), tab);
g_hash_table_replace(statusbar->tabs, GINT_TO_POINTER(true_win), tab);
status_bar_draw();
}

View File

@@ -15,7 +15,6 @@
#include <glib.h>
#include "common.h"
#include "log.h"
#include "xmpp/jid.h"
#define JID_MAX_PART_LEN 1023