1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

Check a logfile parameter is given

Previously this continued with an empty filename, resulting in a broken
config file.

Fixes #1392.
This commit is contained in:
Will Storey 2022-12-18 10:19:13 -08:00 committed by Ailin Nemui
parent 6dfcde5acd
commit 3415718ea7

View File

@ -327,21 +327,34 @@ static void cmd_window_logfile(const char *data)
{ {
LOG_REC *log; LOG_REC *log;
char window[MAX_INT_STRLEN]; char window[MAX_INT_STRLEN];
void *free_arg;
char *fname;
if (!cmd_get_params(data, &free_arg, 1, &fname)) {
return;
}
if (!fname || strlen(fname) == 0) {
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
}
ltoa(window, active_win->refnum); ltoa(window, active_win->refnum);
log = logs_find_item(LOG_ITEM_WINDOW_REFNUM, window, NULL, NULL); log = logs_find_item(LOG_ITEM_WINDOW_REFNUM, window, NULL, NULL);
if (log != NULL) { if (log != NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WINDOWLOG_FILE_LOGGING); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WINDOWLOG_FILE_LOGGING);
cmd_params_free(free_arg);
return; return;
} }
log = log_create_rec(data, MSGLEVEL_ALL); log = log_create_rec(fname, MSGLEVEL_ALL);
log->colorizer = log_colorizer_strip; log->colorizer = log_colorizer_strip;
log_item_add(log, LOG_ITEM_WINDOW_REFNUM, window, NULL); log_item_add(log, LOG_ITEM_WINDOW_REFNUM, window, NULL);
log_update(log); log_update(log);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WINDOWLOG_FILE, data); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WINDOWLOG_FILE, data);
cmd_params_free(free_arg);
} }
/* window's refnum changed - update the logs to log the new window refnum */ /* window's refnum changed - update the logs to log the new window refnum */