fix: address GCC -fanalyzer warnings
Some checks failed
CI Code / Code Coverage (pull_request) Failing after 11m32s
CI Code / Check spelling (pull_request) Failing after 11m46s
CI Code / Check coding style (pull_request) Failing after 12m12s
CI Code / Linux (ubuntu) (pull_request) Failing after 12m40s
CI Code / Linux (debian) (pull_request) Failing after 12m53s
CI Code / Linux (arch) (pull_request) Failing after 13m9s
Some checks failed
CI Code / Code Coverage (pull_request) Failing after 11m32s
CI Code / Check spelling (pull_request) Failing after 11m46s
CI Code / Check coding style (pull_request) Failing after 12m12s
CI Code / Linux (ubuntu) (pull_request) Failing after 12m40s
CI Code / Linux (debian) (pull_request) Failing after 12m53s
CI Code / Linux (arch) (pull_request) Failing after 13m9s
- profanity.c: initialize 'waittime' to 0 (CWE-457) - log.c: remove redundant close(STDERR_FILENO) before dup2 (CWE-687) - cmd_funcs.c: close file handle on OMEMO error path (CWE-401) - account.c: pclose() stream before early returns (CWE-401) - omemo.c: fix double call to omemo_format_fingerprint() leak (CWE-401) - http_download.c: free previous err before overwriting (CWE-401) - iq.c: suppress false-positive malloc-leak from callback ownership
This commit is contained in:
@@ -4972,6 +4972,7 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
|
||||
if (err != NULL) {
|
||||
cons_show_error("%s", err);
|
||||
win_println(window, THEME_ERROR, "-", "%s", err);
|
||||
fclose(fh);
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -178,12 +178,14 @@ account_eval_password(ProfAccount* account)
|
||||
if (!account->password) {
|
||||
log_error("Failed to allocate enough memory to read `eval_password` "
|
||||
"output.");
|
||||
pclose(stream);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
account->password = fgets(account->password, READ_BUF_SIZE, stream);
|
||||
if (!account->password) {
|
||||
log_error("Failed to read password from stream.");
|
||||
pclose(stream);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,6 @@ log_stderr_init(log_level_t level)
|
||||
if (rc != 0)
|
||||
goto err;
|
||||
|
||||
close(STDERR_FILENO);
|
||||
rc = dup2(stderr_pipe[1], STDERR_FILENO);
|
||||
if (rc < 0)
|
||||
goto err_close;
|
||||
|
||||
@@ -537,8 +537,10 @@ omemo_set_device_list(const char* const from, GList* device_list)
|
||||
g_hash_table_iter_init(&iter, known_identities);
|
||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||
if (device_id->data == value) {
|
||||
cons_show("OMEMO: Adding firstusage trust for %s device %d - Fingerprint %s", jid->barejid, GPOINTER_TO_INT(device_id->data), omemo_format_fingerprint(key));
|
||||
omemo_trust(jid->barejid, omemo_format_fingerprint(key));
|
||||
char* formatted = omemo_format_fingerprint(key);
|
||||
cons_show("OMEMO: Adding firstusage trust for %s device %d - Fingerprint %s", jid->barejid, GPOINTER_TO_INT(device_id->data), formatted);
|
||||
omemo_trust(jid->barejid, formatted);
|
||||
free(formatted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ prof_run(gchar* log_level, gchar* account_name, gchar* config_file, gchar* log_f
|
||||
char* line = NULL;
|
||||
GTimer* waittimer = g_timer_new();
|
||||
g_timer_stop(waittimer);
|
||||
int waittime;
|
||||
int waittime = 0;
|
||||
while (cont && !force_quit) {
|
||||
log_stderr_handler();
|
||||
session_check_autoaway();
|
||||
|
||||
@@ -178,6 +178,7 @@ http_file_get(void* userdata)
|
||||
}
|
||||
|
||||
if (ftell(outfh) == 0) {
|
||||
free(err);
|
||||
err = strdup("Output file is empty.");
|
||||
}
|
||||
|
||||
@@ -185,6 +186,7 @@ http_file_get(void* userdata)
|
||||
curl_global_cleanup();
|
||||
|
||||
if (fclose(outfh) == EOF) {
|
||||
free(err);
|
||||
err = strdup(g_strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
@@ -355,6 +355,9 @@ _iq_id_handler_free(ProfIqHandler* handler)
|
||||
free(handler);
|
||||
}
|
||||
|
||||
/* Analyzer cannot track ownership transfer through callback registration */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
||||
void
|
||||
iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata)
|
||||
{
|
||||
@@ -367,6 +370,7 @@ iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback
|
||||
g_hash_table_insert(id_handlers, strdup(id), handler);
|
||||
}
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void
|
||||
iq_autoping_timer_cancel(void)
|
||||
@@ -538,6 +542,9 @@ iq_last_activity_request(const char* jid)
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
/* Ownership transferred via iq_id_handler_add callback */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
||||
void
|
||||
iq_room_info_request(const char* const room, gboolean display_result)
|
||||
{
|
||||
@@ -556,6 +563,7 @@ iq_room_info_request(const char* const room, gboolean display_result)
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void
|
||||
iq_send_caps_request_for_jid(const char* const to, const char* const id,
|
||||
@@ -721,6 +729,9 @@ iq_room_config_cancel(ProfConfWin* confwin)
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
/* Ownership transferred via iq_id_handler_add callback */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
||||
void
|
||||
iq_room_affiliation_list(const char* const room, char* affiliation, bool show_ui_message)
|
||||
{
|
||||
@@ -795,6 +806,7 @@ iq_room_role_set(const char* const room, const char* const nick, char* role,
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void
|
||||
iq_room_role_list(const char* const room, char* role)
|
||||
@@ -1229,6 +1241,9 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ownership of 'data' transferred to wins_new_config callbacks */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
||||
static int
|
||||
_command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
@@ -1351,6 +1366,7 @@ _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata
|
||||
|
||||
return 0;
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
static int
|
||||
_enable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
|
||||
Reference in New Issue
Block a user