merge/upstream-full #105

Manually merged
jabber.developer merged 407 commits from merge/upstream-full into master 2026-05-26 17:54:34 +00:00
303 changed files with 10656 additions and 9848 deletions
Showing only changes of commit d3d7c328b4 - Show all commits

View File

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

View File

@@ -806,6 +806,10 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
key_tag = gcry_malloc_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH);
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);

View File

@@ -121,6 +121,12 @@ launch_editor(gchar* initial_content, void (*callback)(gchar* content, void* dat
ui_suspend();
// 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) {
log_error("[Editor] Failed to fork: %s", strerror(errno));

View File

@@ -55,6 +55,8 @@ static GTimeZone* tz;
static StatusBar* statusbar;
static WINDOW* statusbar_win;
jabber.developer marked this conversation as resolved Outdated

All these guint might lead to unexpected bugs.

Many developers (and some large development houses, such as Google) believe that developers should generally avoid unsigned integers.
https://www.learncpp.com/cpp-tutorial/unsigned-integers-and-why-to-avoid-them/

The fact that unsigned arithmetic doesn't model the behavior of a simple integer, but is instead defined by the standard to model modular arithmetic (wrapping around on overflow/underflow), means that a significant class of bugs cannot be diagnosed by the compiler. In other cases, the defined behavior impedes optimization.

That said, mixing signedness of integer types is responsible for an equally large class of problems. The best advice we can provide: try to use iterators and containers rather than pointers and sizes, try not to mix signedness, and try to avoid unsigned types (except for representing bitfields or modular arithmetic). Do not use an unsigned type merely to assert that a variable is non-negative.

https://google.github.io/styleguide/cppguide.html

We should discuss style guide for CProof.

All these `guint` might lead to unexpected bugs. > Many developers (and some large development houses, such as Google) believe that developers should generally avoid unsigned integers. https://www.learncpp.com/cpp-tutorial/unsigned-integers-and-why-to-avoid-them/ > The fact that unsigned arithmetic doesn't model the behavior of a simple integer, but is instead defined by the standard to model modular arithmetic (wrapping around on overflow/underflow), means that a significant class of bugs cannot be diagnosed by the compiler. In other cases, the defined behavior impedes optimization. > That said, mixing signedness of integer types is responsible for an equally large class of problems. The best advice we can provide: try to use iterators and containers rather than pointers and sizes, try not to mix signedness, and try to avoid unsigned types (except for representing bitfields or modular arithmetic). Do not use an unsigned type merely to assert that a variable is non-negative. https://google.github.io/styleguide/cppguide.html We should discuss style guide for CProof.

Updated

Updated
#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);
@@ -157,7 +159,7 @@ void
status_bar_current(guint i)
{
if (i == 0) {
statusbar->current_tab = 10;
statusbar->current_tab = CONSOLE_TAB_ID;
} else {
statusbar->current_tab = i;
}

View File

@@ -32,6 +32,7 @@ Jid*
jid_create(const gchar* const str)
{
if (!jid_is_valid(str)) {
log_debug("[JID] invalid JID: '%s'", str ?: "(null)");
return NULL;
}