Compare commits

..

1 Commits

Author SHA1 Message Date
97fd81b60b fix(review): address F1, F6, F9, F16 from deep review
All checks were successful
CI Code / Check spelling (pull_request) Successful in 15s
CI Code / Check coding style (pull_request) Successful in 32s
CI Code / Linux (debian) (pull_request) Successful in 5m1s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m2s
CI Code / Linux (arch) (pull_request) Successful in 5m47s
CI Code / Code Coverage (pull_request) Successful in 6m35s
- src/log.c (F16): log_stderr_init no longer closes STDERR_FILENO
  immediately after dup2(). The previous 'close(dup_fd)' closed fd 2
  because dup2 returns newfd on success; the in-app stderr capture
  pipe was silently dead, dropping libstrophe/openssl error output.
  Close the original stderr_pipe[1] instead and remember that the
  write end now lives at STDERR_FILENO so _log_stderr_close stays
  correct.

- src/database_sqlite.c (F1): NULL-check sqlite3_mprintf result
  before passing it to sqlite3_exec in the DbVersion bootstrap path.

- src/tools/editor.c (F9): drop three orphan #includes
  (<fcntl.h>, <pthread.h>, <readline/readline.h>) left behind when
  9b03e3a50 removed the async-editor path.

- src/xmpp/jid.c (F6): match the g_new0 allocation in jid_create
  with g_free in jid_destroy. Same behaviour on glibc but stops
  being a foot-gun under custom glib allocators.

Verified with ci-build.sh in Debian docker: all 4 configs pass
(644/0, 605/0, 605/0, 644/0 unit + 130/0 functional).
2026-05-21 15:34:33 +03:00
5 changed files with 16 additions and 23 deletions

View File

@@ -43,8 +43,7 @@ _sanitize_account_name(const char* const name)
gchar* sanitized = g_strdup(name);
gchar* p = sanitized;
while (*p) {
// GKeyFile special characters: [ ] = # \n \r
if (*p == '[' || *p == ']' || *p == '=' || *p == '#' || *p == '\n' || *p == '\r') {
if (*p == '[' || *p == ']' || *p == '=') {
*p = '_';
}
p++;

View File

@@ -804,16 +804,8 @@ 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) {
log_error("[OMEMO][SEND] cannot generate random key/IV");
goto out;
}
iv = key + AES128_GCM_KEY_LENGTH;
res = aes128gcm_encrypt(ciphertext, &ciphertext_len, tag, &tag_len, (const unsigned char* const)message, strlen(message), iv, key);
@@ -1997,6 +1989,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,12 +121,6 @@ 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);
pid_t pid = fork();
if (pid == -1) {
log_error("[Editor] Failed to fork: %s", strerror(errno));

View File

@@ -55,8 +55,6 @@ static GTimeZone* tz;
static StatusBar* statusbar;
static WINDOW* statusbar_win;
#define CONSOLE_TAB_ID 10 // Console tab ID in status bar hash table
void _get_range_bounds(guint* start, guint* end, gboolean is_static);
static guint _status_bar_draw_time(guint pos);
static guint _status_bar_draw_maintext(guint pos);
@@ -159,7 +157,7 @@ void
status_bar_current(guint i)
{
if (i == 0) {
statusbar->current_tab = CONSOLE_TAB_ID;
statusbar->current_tab = 10;
} else {
statusbar->current_tab = i;
}
@@ -170,7 +168,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 +181,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 +212,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
@@ -33,7 +32,6 @@ Jid*
jid_create(const gchar* const str)
{
if (!jid_is_valid(str)) {
log_debug("[JID] invalid JID: '%s'", str ?: "(null)");
return NULL;
}