summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/log.c23
-rw-r--r--src/fe-common/core/fe-windows.c5
2 files changed, 17 insertions, 11 deletions
diff --git a/src/core/log.c b/src/core/log.c
index c9598ba2..55e0c5f6 100644
--- a/src/core/log.c
+++ b/src/core/log.c
@@ -70,27 +70,31 @@ static void log_write_timestamp(int handle, const char *format,
if (*format == '\0') return;
tm = localtime(&stamp);
-
- str[sizeof(str)-1] = '\0';
- strftime(str, sizeof(str)-1, format, tm);
-
- write(handle, str, strlen(str));
- if (suffix != NULL) write(handle, suffix, strlen(suffix));
+ if (strftime(str, sizeof(str), format, tm) > 0) {
+ write(handle, str, strlen(str));
+ if (suffix != NULL) write(handle, suffix, strlen(suffix));
+ }
}
static char *log_filename(LOG_REC *log)
{
char *str, fname[1024];
struct tm *tm;
+ size_t ret;
time_t now;
now = time(NULL);
tm = localtime(&now);
str = convert_home(log->fname);
- strftime(fname, sizeof(fname), str, tm);
+ ret = strftime(fname, sizeof(fname), str, tm);
g_free(str);
+ if (ret <= 0) {
+ g_warning("log_filename() : strftime() failed");
+ return NULL;
+ }
+
return g_strdup(fname);
}
@@ -104,8 +108,9 @@ int log_start_logging(LOG_REC *log)
/* Append/create log file */
g_free_not_null(log->real_fname);
log->real_fname = log_filename(log);
- log->handle = open(log->real_fname, O_WRONLY | O_APPEND | O_CREAT,
- log_file_create_mode);
+ log->handle = log->real_fname == NULL ? -1 :
+ open(log->real_fname, O_WRONLY | O_APPEND | O_CREAT,
+ log_file_create_mode);
if (log->handle == -1) {
signal_emit("log create failed", 1, log);
log->failed = TRUE;
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c
index 5f2af823..fba29a51 100644
--- a/src/fe-common/core/fe-windows.c
+++ b/src/fe-common/core/fe-windows.c
@@ -421,13 +421,14 @@ static void sig_server_disconnected(SERVER_REC *server)
static void sig_print_text(void)
{
GSList *tmp;
- char month[10];
+ char month[100];
time_t t;
struct tm *tm;
t = time(NULL);
tm = localtime(&t);
- strftime(month, sizeof(month)-1, "%b", tm);
+ if (strftime(month, sizeof(month), "%b", tm) <= 0)
+ month[0] = '\0';
if (tm->tm_hour != 0 || tm->tm_min != 0)
return;