mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 08:13:14 +02:00
core: check pointer returned by function localtime
This commit is contained in:
@@ -564,9 +564,9 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
|
||||
if (weechat_config_boolean (logger_config_file_info_lines)
|
||||
&& logger_buffer->write_start_info_line)
|
||||
{
|
||||
buf_time[0] = '\0';
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
buf_time[0] = '\0';
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (buf_time, sizeof (buf_time) - 1,
|
||||
@@ -624,9 +624,9 @@ logger_stop (struct t_logger_buffer *logger_buffer, int write_info_line)
|
||||
{
|
||||
if (write_info_line && weechat_config_boolean (logger_config_file_info_lines))
|
||||
{
|
||||
buf_time[0] = '\0';
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
buf_time[0] = '\0';
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (buf_time, sizeof (buf_time) - 1,
|
||||
@@ -1180,8 +1180,8 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
|
||||
&& (date > 0)
|
||||
&& (line_log_level <= ptr_logger_buffer->log_level))
|
||||
{
|
||||
date_tmp = localtime (&date);
|
||||
buf_time[0] = '\0';
|
||||
date_tmp = localtime (&date);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (buf_time, sizeof (buf_time) - 1,
|
||||
|
||||
@@ -95,15 +95,22 @@ relay_buffer_refresh (const char *hotlist)
|
||||
}
|
||||
}
|
||||
|
||||
date_start[0] = '\0';
|
||||
date_tmp = localtime (&(ptr_client->start_time));
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
date_end[0] = '\0';
|
||||
if (ptr_client->end_time > 0)
|
||||
{
|
||||
date_tmp = localtime (&(ptr_client->end_time));
|
||||
strftime (date_end, sizeof (date_end),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date_end, sizeof (date_end),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/* first line with status and start time */
|
||||
|
||||
@@ -54,13 +54,21 @@ relay_command_client_list (int full)
|
||||
for (ptr_client = relay_clients; ptr_client;
|
||||
ptr_client = ptr_client->next_client)
|
||||
{
|
||||
date_start[0] = '\0';
|
||||
date_tmp = localtime (&(ptr_client->start_time));
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
|
||||
date_activity[0] = '\0';
|
||||
date_tmp = localtime (&(ptr_client->last_activity));
|
||||
strftime (date_activity, sizeof (date_activity),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date_activity, sizeof (date_activity),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
|
||||
if (full)
|
||||
{
|
||||
@@ -121,9 +129,13 @@ relay_command_server_list ()
|
||||
for (ptr_server = relay_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
date_start[0] = '\0';
|
||||
date_tmp = localtime (&(ptr_server->start_time));
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date_start, sizeof (date_start),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
|
||||
weechat_printf (NULL,
|
||||
_(" port %s%d%s, relay: %s%s.%s%s, started on: %s"),
|
||||
|
||||
@@ -4706,15 +4706,19 @@ weechat_guile_api_infolist_time (SCM infolist, SCM variable)
|
||||
{
|
||||
char timebuffer[64], *result;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
SCM return_value;
|
||||
|
||||
API_FUNC(1, "infolist_time", API_RETURN_EMPTY);
|
||||
if (!scm_is_string (infolist) || !scm_is_string (variable))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_infolist_time (script_str2ptr (scm_i_string_chars (infolist)),
|
||||
scm_i_string_chars (variable));
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
@@ -4976,16 +4980,20 @@ weechat_guile_api_hdata_time (SCM hdata, SCM pointer, SCM name)
|
||||
{
|
||||
char timebuffer[64], *result;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
SCM return_value;
|
||||
|
||||
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
|
||||
if (!scm_is_string (hdata) || !scm_is_string (pointer) || !scm_is_string (name))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_hdata_time (script_str2ptr (scm_i_string_chars (hdata)),
|
||||
script_str2ptr (scm_i_string_chars (pointer)),
|
||||
scm_i_string_chars (name));
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
|
||||
@@ -5179,6 +5179,7 @@ weechat_lua_api_infolist_time (lua_State *L)
|
||||
{
|
||||
const char *infolist, *variable;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
char timebuffer[64], *result;
|
||||
|
||||
API_FUNC(1, "infolist_time", API_RETURN_EMPTY);
|
||||
@@ -5188,9 +5189,12 @@ weechat_lua_api_infolist_time (lua_State *L)
|
||||
infolist = lua_tostring (lua_current_interpreter, -2);
|
||||
variable = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_infolist_time (script_str2ptr (infolist),
|
||||
variable);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
@@ -5490,6 +5494,7 @@ weechat_lua_api_hdata_time (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer, *name;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
char timebuffer[64], *result;
|
||||
|
||||
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
|
||||
@@ -5500,10 +5505,13 @@ weechat_lua_api_hdata_time (lua_State *L)
|
||||
pointer = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
|
||||
@@ -4922,6 +4922,7 @@ XS (XS_weechat_api_infolist_pointer)
|
||||
XS (XS_weechat_api_infolist_time)
|
||||
{
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
char timebuffer[64], *result, *infolist, *variable;
|
||||
dXSARGS;
|
||||
|
||||
@@ -4931,8 +4932,12 @@ XS (XS_weechat_api_infolist_time)
|
||||
|
||||
infolist = SvPV_nolen (ST (0));
|
||||
variable = SvPV_nolen (ST (1));
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_infolist_time (script_str2ptr (infolist), variable);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
@@ -5224,6 +5229,7 @@ XS (XS_weechat_api_hdata_pointer)
|
||||
XS (XS_weechat_api_hdata_time)
|
||||
{
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
char timebuffer[64], *result, *hdata, *pointer, *name;
|
||||
dXSARGS;
|
||||
|
||||
@@ -5235,10 +5241,13 @@ XS (XS_weechat_api_hdata_time)
|
||||
pointer = SvPV_nolen (ST (1));
|
||||
name = SvPV_nolen (ST (2));
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
|
||||
@@ -5104,6 +5104,7 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *infolist, *variable, timebuffer[64], *result;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
PyObject *return_value;
|
||||
|
||||
API_FUNC(1, "infolist_time", API_RETURN_EMPTY);
|
||||
@@ -5112,9 +5113,12 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_infolist_time (script_str2ptr (infolist),
|
||||
variable);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
@@ -5405,6 +5409,7 @@ weechat_python_api_hdata_time (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *pointer, *name, timebuffer[64], *result;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
PyObject *return_value;
|
||||
|
||||
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
|
||||
@@ -5414,10 +5419,13 @@ weechat_python_api_hdata_time (PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
|
||||
@@ -5857,6 +5857,7 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable)
|
||||
{
|
||||
char *c_infolist, *c_variable, timebuffer[64], *result;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
VALUE return_value;
|
||||
|
||||
API_FUNC(1, "infolist_time", API_RETURN_EMPTY);
|
||||
@@ -5869,8 +5870,11 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable)
|
||||
c_infolist = StringValuePtr (infolist);
|
||||
c_variable = StringValuePtr (variable);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_infolist_time (script_str2ptr (c_infolist), c_variable);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
@@ -6221,6 +6225,7 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name, timebuffer[64], *result;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
VALUE return_value;
|
||||
|
||||
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
|
||||
@@ -6235,10 +6240,13 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_hdata_time (script_str2ptr (c_hdata),
|
||||
script_str2ptr (c_pointer),
|
||||
c_name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
|
||||
@@ -5607,6 +5607,7 @@ weechat_tcl_api_infolist_time (ClientData clientData, Tcl_Interp *interp,
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
char timebuffer[64], *result, *infolist, *variable;
|
||||
int i;
|
||||
|
||||
@@ -5616,9 +5617,12 @@ weechat_tcl_api_infolist_time (ClientData clientData, Tcl_Interp *interp,
|
||||
|
||||
infolist = Tcl_GetStringFromObj (objv[1], &i);
|
||||
variable = Tcl_GetStringFromObj (objv[2], &i);
|
||||
time = weechat_infolist_time (script_str2ptr (infolist), variable);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_infolist_time (script_str2ptr (infolist), variable);
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
@@ -5921,6 +5925,7 @@ weechat_tcl_api_hdata_time (ClientData clientData, Tcl_Interp *interp,
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
char timebuffer[64], *result, *hdata, *pointer, *name;
|
||||
int i;
|
||||
|
||||
@@ -5932,11 +5937,13 @@ weechat_tcl_api_hdata_time (ClientData clientData, Tcl_Interp *interp,
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
name = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
timebuffer[0] = '\0';
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
|
||||
@@ -122,9 +122,13 @@ xfer_buffer_refresh (const char *hotlist)
|
||||
if (XFER_IS_CHAT(ptr_xfer->type))
|
||||
{
|
||||
/* display second line for chat with status and date */
|
||||
date[0] = '\0';
|
||||
date_tmp = localtime (&(ptr_xfer->start_time));
|
||||
strftime (date, sizeof (date),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date, sizeof (date),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 3,
|
||||
"%s%s%s %s%s%s%s%s",
|
||||
weechat_color(str_color),
|
||||
|
||||
@@ -129,9 +129,13 @@ xfer_command_xfer_list (int full)
|
||||
}
|
||||
else
|
||||
{
|
||||
date[0] = '\0';
|
||||
date_tmp = localtime (&(ptr_xfer->start_time));
|
||||
strftime (date, sizeof (date),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date, sizeof (date),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
weechat_printf (NULL,
|
||||
/* TRANSLATORS: "%s" after "started on" is a date */
|
||||
_("%3d. %s, chat with %s (local nick: %s), "
|
||||
@@ -165,9 +169,13 @@ xfer_command_xfer_list (int full)
|
||||
(ptr_xfer->address >> 8) & 0xff,
|
||||
ptr_xfer->address & 0xff,
|
||||
ptr_xfer->port);
|
||||
date[0] = '\0';
|
||||
date_tmp = localtime (&(ptr_xfer->start_transfer));
|
||||
strftime (date, sizeof (date),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
if (date_tmp)
|
||||
{
|
||||
strftime (date, sizeof (date),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
}
|
||||
weechat_printf (NULL,
|
||||
/* TRANSLATORS: "%s" after "started on" is a date */
|
||||
_(" fast_send: %s, blocksize: %d, "
|
||||
|
||||
Reference in New Issue
Block a user