mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Merge pull request #147 from ahf/bugfix-143
Fix use-after-free bug with cached settings values
This commit is contained in:
commit
ec0360b921
@ -57,7 +57,7 @@ static char *last_sent_msg, *last_sent_msg_body;
|
|||||||
static char *last_privmsg_from, *last_public_from;
|
static char *last_privmsg_from, *last_public_from;
|
||||||
static char *sysname, *sysrelease, *sysarch;
|
static char *sysname, *sysrelease, *sysarch;
|
||||||
|
|
||||||
static const char *timestamp_format;
|
static char *timestamp_format;
|
||||||
static int timestamp_seconds;
|
static int timestamp_seconds;
|
||||||
static time_t last_timestamp;
|
static time_t last_timestamp;
|
||||||
|
|
||||||
@ -567,7 +567,9 @@ static int sig_timer(void)
|
|||||||
|
|
||||||
static void read_settings(void)
|
static void read_settings(void)
|
||||||
{
|
{
|
||||||
timestamp_format = settings_get_str("timestamp_format");
|
g_free_not_null(timestamp_format);
|
||||||
|
timestamp_format = g_strdup(settings_get_str("timestamp_format"));
|
||||||
|
|
||||||
timestamp_seconds =
|
timestamp_seconds =
|
||||||
strstr(timestamp_format, "%r") != NULL ||
|
strstr(timestamp_format, "%r") != NULL ||
|
||||||
strstr(timestamp_format, "%s") != NULL ||
|
strstr(timestamp_format, "%s") != NULL ||
|
||||||
@ -710,10 +712,14 @@ void expandos_deinit(void)
|
|||||||
g_hash_table_foreach_remove(expandos, free_expando, NULL);
|
g_hash_table_foreach_remove(expandos, free_expando, NULL);
|
||||||
g_hash_table_destroy(expandos);
|
g_hash_table_destroy(expandos);
|
||||||
|
|
||||||
g_free_not_null(last_sent_msg); g_free_not_null(last_sent_msg_body);
|
g_free_not_null(last_sent_msg);
|
||||||
g_free_not_null(last_privmsg_from); g_free_not_null(last_public_from);
|
g_free_not_null(last_sent_msg_body);
|
||||||
g_free_not_null(sysname); g_free_not_null(sysrelease);
|
g_free_not_null(last_privmsg_from);
|
||||||
|
g_free_not_null(last_public_from);
|
||||||
|
g_free_not_null(sysname);
|
||||||
|
g_free_not_null(sysrelease);
|
||||||
g_free_not_null(sysarch);
|
g_free_not_null(sysarch);
|
||||||
|
g_free_not_null(timestamp_format);
|
||||||
|
|
||||||
g_source_remove(timer_tag);
|
g_source_remove(timer_tag);
|
||||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||||
|
@ -41,7 +41,7 @@ static const char *log_item_types[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *log_timestamp;
|
static char *log_timestamp;
|
||||||
static int log_file_create_mode;
|
static int log_file_create_mode;
|
||||||
static int log_dir_create_mode;
|
static int log_dir_create_mode;
|
||||||
static int rotate_tag;
|
static int rotate_tag;
|
||||||
@ -558,7 +558,9 @@ static void log_read_config(void)
|
|||||||
|
|
||||||
static void read_settings(void)
|
static void read_settings(void)
|
||||||
{
|
{
|
||||||
log_timestamp = settings_get_str("log_timestamp");
|
g_free_not_null(log_timestamp);
|
||||||
|
log_timestamp = g_strdup(settings_get_str("log_timestamp"));
|
||||||
|
|
||||||
log_file_create_mode = octal2dec(settings_get_int("log_create_mode"));
|
log_file_create_mode = octal2dec(settings_get_int("log_create_mode"));
|
||||||
|
|
||||||
log_dir_create_mode = log_file_create_mode;
|
log_dir_create_mode = log_file_create_mode;
|
||||||
@ -595,6 +597,8 @@ void log_deinit(void)
|
|||||||
while (logs != NULL)
|
while (logs != NULL)
|
||||||
log_close(logs->data);
|
log_close(logs->data);
|
||||||
|
|
||||||
|
g_free_not_null(log_timestamp);
|
||||||
|
|
||||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
signal_remove("setup reread", (SIGNAL_FUNC) log_read_config);
|
signal_remove("setup reread", (SIGNAL_FUNC) log_read_config);
|
||||||
signal_remove("irssi init finished", (SIGNAL_FUNC) log_read_config);
|
signal_remove("irssi init finished", (SIGNAL_FUNC) log_read_config);
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
static int keep_privates_count, keep_publics_count;
|
static int keep_privates_count, keep_publics_count;
|
||||||
static int completion_lowercase;
|
static int completion_lowercase;
|
||||||
static const char *completion_char, *cmdchars;
|
static char *completion_char, *cmdchars;
|
||||||
static GSList *global_lastmsgs;
|
static GSList *global_lastmsgs;
|
||||||
static int completion_auto, completion_strict;
|
static int completion_auto, completion_strict;
|
||||||
|
|
||||||
@ -1126,11 +1126,16 @@ static void read_settings(void)
|
|||||||
keep_privates_count = settings_get_int("completion_keep_privates");
|
keep_privates_count = settings_get_int("completion_keep_privates");
|
||||||
keep_publics_count = settings_get_int("completion_keep_publics");
|
keep_publics_count = settings_get_int("completion_keep_publics");
|
||||||
completion_lowercase = settings_get_bool("completion_nicks_lowercase");
|
completion_lowercase = settings_get_bool("completion_nicks_lowercase");
|
||||||
completion_char = settings_get_str("completion_char");
|
|
||||||
cmdchars = settings_get_str("cmdchars");
|
|
||||||
completion_auto = settings_get_bool("completion_auto");
|
completion_auto = settings_get_bool("completion_auto");
|
||||||
completion_strict = settings_get_bool("completion_strict");
|
completion_strict = settings_get_bool("completion_strict");
|
||||||
|
|
||||||
|
g_free_not_null(completion_char);
|
||||||
|
completion_char = g_strdup(settings_get_str("completion_char"));
|
||||||
|
|
||||||
|
g_free_not_null(cmdchars);
|
||||||
|
cmdchars = g_strdup(settings_get_str("cmdchars"));
|
||||||
|
|
||||||
if (*completion_char == '\0') {
|
if (*completion_char == '\0') {
|
||||||
/* this would break.. */
|
/* this would break.. */
|
||||||
completion_auto = FALSE;
|
completion_auto = FALSE;
|
||||||
@ -1220,4 +1225,7 @@ void chat_completion_deinit(void)
|
|||||||
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
||||||
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
||||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
|
|
||||||
|
g_free_not_null(completion_char);
|
||||||
|
g_free_not_null(cmdchars);
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,11 @@
|
|||||||
|
|
||||||
static int autolog_level;
|
static int autolog_level;
|
||||||
static int autoremove_tag;
|
static int autoremove_tag;
|
||||||
static const char *autolog_path;
|
static char *autolog_path;
|
||||||
|
|
||||||
static THEME_REC *log_theme;
|
static THEME_REC *log_theme;
|
||||||
static int skip_next_printtext;
|
static int skip_next_printtext;
|
||||||
static const char *log_theme_name;
|
static char *log_theme_name;
|
||||||
|
|
||||||
static int log_dir_create_mode;
|
static int log_dir_create_mode;
|
||||||
|
|
||||||
@ -677,7 +677,9 @@ static void read_settings(void)
|
|||||||
int old_autolog = autolog_level;
|
int old_autolog = autolog_level;
|
||||||
int log_file_create_mode;
|
int log_file_create_mode;
|
||||||
|
|
||||||
autolog_path = settings_get_str("autolog_path");
|
g_free_not_null(autolog_path);
|
||||||
|
autolog_path = g_strdup(settings_get_str("autolog_path"));
|
||||||
|
|
||||||
autolog_level = !settings_get_bool("autolog") ? 0 :
|
autolog_level = !settings_get_bool("autolog") ? 0 :
|
||||||
settings_get_level("autolog_level");
|
settings_get_level("autolog_level");
|
||||||
|
|
||||||
@ -687,9 +689,14 @@ static void read_settings(void)
|
|||||||
/* write to log files with different theme? */
|
/* write to log files with different theme? */
|
||||||
if (log_theme_name != NULL)
|
if (log_theme_name != NULL)
|
||||||
signal_remove("print format", (SIGNAL_FUNC) sig_print_format);
|
signal_remove("print format", (SIGNAL_FUNC) sig_print_format);
|
||||||
log_theme_name = settings_get_str("log_theme");
|
|
||||||
if (*log_theme_name == '\0')
|
g_free_not_null(log_theme_name);
|
||||||
|
log_theme_name = g_strdup(settings_get_str("log_theme"));
|
||||||
|
|
||||||
|
if (*log_theme_name == '\0') {
|
||||||
|
g_free(log_theme_name);
|
||||||
log_theme_name = NULL;
|
log_theme_name = NULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
signal_add("print format", (SIGNAL_FUNC) sig_print_format);
|
signal_add("print format", (SIGNAL_FUNC) sig_print_format);
|
||||||
|
|
||||||
@ -776,4 +783,7 @@ void fe_log_deinit(void)
|
|||||||
|
|
||||||
if (autolog_ignore_targets != NULL)
|
if (autolog_ignore_targets != NULL)
|
||||||
g_strfreev(autolog_ignore_targets);
|
g_strfreev(autolog_ignore_targets);
|
||||||
|
|
||||||
|
g_free_not_null(autolog_path);
|
||||||
|
g_free_not_null(log_theme_name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user