diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-09-22 21:50:01 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-09-23 15:06:28 +0200 |
commit | 5aab494dd63e6cbbbb54fa0e362ae64e85dcadb3 (patch) | |
tree | e459fec713103315d7ae30aabd2269252ec77ab0 /src/plugins | |
parent | ae66a4d8a586555104dfe633a97fa4a2f17db531 (diff) | |
download | weechat-5aab494dd63e6cbbbb54fa0e362ae64e85dcadb3.zip |
core, plugins: check return code of strftime function
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/exec/exec-command.c | 10 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 5 | ||||
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 7 | ||||
-rw-r--r-- | src/plugins/logger/logger.c | 24 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 5 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 5 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 5 | ||||
-rw-r--r-- | src/plugins/relay/irc/relay-irc.c | 6 | ||||
-rw-r--r-- | src/plugins/relay/relay-buffer.c | 10 | ||||
-rw-r--r-- | src/plugins/relay/relay-command.c | 15 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 5 | ||||
-rw-r--r-- | src/plugins/script/script-buffer.c | 16 | ||||
-rw-r--r-- | src/plugins/script/script-mouse.c | 6 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 5 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-callback.c | 8 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-buffer.c | 5 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-command.c | 10 |
17 files changed, 96 insertions, 51 deletions
diff --git a/src/plugins/exec/exec-command.c b/src/plugins/exec/exec-command.c index bcb82e994..7b3e04ffc 100644 --- a/src/plugins/exec/exec-command.c +++ b/src/plugins/exec/exec-command.c @@ -108,11 +108,13 @@ exec_command_list () { /* process has ended */ local_time = localtime (&ptr_exec_cmd->start_time); - strftime (str_time1, sizeof (str_time1), - "%Y-%m-%d %H:%M:%S", local_time); + if (strftime (str_time1, sizeof (str_time1), + "%Y-%m-%d %H:%M:%S", local_time) == 0) + str_time1[0] = '\0'; local_time = localtime (&ptr_exec_cmd->end_time); - strftime (str_time2, sizeof (str_time2), - "%Y-%m-%d %H:%M:%S", local_time); + if (strftime (str_time2, sizeof (str_time2), + "%Y-%m-%d %H:%M:%S", local_time) == 0) + str_time2[0] = '\0'; weechat_printf (NULL, " %s%s%s %d%s%s%s: %s\"%s%s%s\"%s (%s -> %s, %s)", weechat_color (weechat_config_string (exec_config_color_flag_finished)), diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index b9f2c9e9b..c465fb9b7 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -4321,7 +4321,10 @@ weechat_guile_api_infolist_time (SCM infolist, SCM variable) API_SCM_TO_STRING(variable)); date_tmp = localtime (&time); if (date_tmp) - strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); + { + if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0) + timebuffer[0] = '\0'; + } result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index f875322db..1c42e6eb7 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -452,9 +452,10 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format) now = time (NULL); local_time = localtime (&now); setlocale (LC_ALL, "C"); - strftime (buf, sizeof (buf), - weechat_config_string (irc_config_look_ctcp_time_format), - local_time); + if (strftime (buf, sizeof (buf), + weechat_config_string (irc_config_look_ctcp_time_format), + local_time) == 0) + buf[0] = '\0'; setlocale (LC_ALL, ""); temp = weechat_string_replace (res, "$time", buf); free (res); diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index 7df2561ba..9cfe4604f 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -93,7 +93,8 @@ logger_get_file_path () seconds = time (NULL); date_tmp = localtime (&seconds); path2[0] = '\0'; - strftime (path2, length - 1, path, date_tmp); + if (strftime (path2, length - 1, path, date_tmp) == 0) + path2[0] = '\0'; if (weechat_logger_plugin->debug) { @@ -573,9 +574,10 @@ logger_write_line (struct t_logger_buffer *logger_buffer, date_tmp = localtime (&seconds); if (date_tmp) { - strftime (buf_time, sizeof (buf_time) - 1, - weechat_config_string (logger_config_file_time_format), - date_tmp); + if (strftime (buf_time, sizeof (buf_time) - 1, + weechat_config_string (logger_config_file_time_format), + date_tmp) == 0) + buf_time[0] = '\0'; } snprintf (buf_beginning, sizeof (buf_beginning), _("%s\t**** Beginning of log ****"), @@ -633,9 +635,10 @@ logger_stop (struct t_logger_buffer *logger_buffer, int write_info_line) date_tmp = localtime (&seconds); if (date_tmp) { - strftime (buf_time, sizeof (buf_time) - 1, - weechat_config_string (logger_config_file_time_format), - date_tmp); + if (strftime (buf_time, sizeof (buf_time) - 1, + weechat_config_string (logger_config_file_time_format), + date_tmp) == 0) + buf_time[0] = '\0'; } logger_write_line (logger_buffer, _("%s\t**** End of log ****"), @@ -1268,9 +1271,10 @@ logger_print_cb (const void *pointer, void *data, date_tmp = localtime (&date); if (date_tmp) { - strftime (buf_time, sizeof (buf_time) - 1, - weechat_config_string (logger_config_file_time_format), - date_tmp); + if (strftime (buf_time, sizeof (buf_time) - 1, + weechat_config_string (logger_config_file_time_format), + date_tmp) == 0) + buf_time[0] = '\0'; } logger_write_line (ptr_logger_buffer, diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 144c8f7b4..09b085cf9 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -4580,7 +4580,10 @@ API_FUNC(infolist_time) variable); date_tmp = localtime (&time); if (date_tmp) - strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); + { + if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0) + timebuffer[0] = '\0'; + } result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index e6960c73a..183faa062 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -4493,7 +4493,10 @@ API_FUNC(infolist_time) time = weechat_infolist_time (API_STR2PTR(infolist), variable); date_tmp = localtime (&time); if (date_tmp) - strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); + { + if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0) + timebuffer[0] = '\0'; + } result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 874c51f99..52222cbbe 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -4510,7 +4510,10 @@ API_FUNC(infolist_time) variable); date_tmp = localtime (&time); if (date_tmp) - strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); + { + if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0) + timebuffer[0] = '\0'; + } result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/relay/irc/relay-irc.c b/src/plugins/relay/irc/relay-irc.c index 1da5835b9..813f65cac 100644 --- a/src/plugins/relay/irc/relay-irc.c +++ b/src/plugins/relay/irc/relay-irc.c @@ -726,7 +726,8 @@ relay_irc_get_line_info (struct t_relay_client *client, && time_format && time_format[0]) { tm = localtime (&msg_date); - strftime (str_time, sizeof (str_time), time_format, tm); + if (strftime (str_time, sizeof (str_time), time_format, tm) == 0) + str_time[0] = '\0'; length = strlen (str_time) + strlen (pos) + 1; *message = malloc (length); if (*message) @@ -741,7 +742,8 @@ relay_irc_get_line_info (struct t_relay_client *client, && (RELAY_IRC_DATA(client, server_capabilities) & (1 << RELAY_IRC_CAPAB_SERVER_TIME))) { tm = gmtime (&msg_date); - strftime (str_time, sizeof (str_time), "%Y-%m-%dT%H:%M:%S", tm); + if (strftime (str_time, sizeof (str_time), "%Y-%m-%dT%H:%M:%S", tm) == 0) + str_time[0] = '\0'; snprintf (str_tag, sizeof (str_tag), "@time=%s.000Z ", str_time); *tags = strdup (str_tag); } diff --git a/src/plugins/relay/relay-buffer.c b/src/plugins/relay/relay-buffer.c index 5a0f8f87b..5d5d02632 100644 --- a/src/plugins/relay/relay-buffer.c +++ b/src/plugins/relay/relay-buffer.c @@ -96,8 +96,9 @@ relay_buffer_refresh (const char *hotlist) date_tmp = localtime (&(ptr_client->start_time)); if (date_tmp) { - strftime (str_date_start, sizeof (str_date_start), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (str_date_start, sizeof (str_date_start), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + str_date_start[0] = '\0'; } str_date_end[0] = '-'; str_date_end[1] = '\0'; @@ -106,8 +107,9 @@ relay_buffer_refresh (const char *hotlist) date_tmp = localtime (&(ptr_client->end_time)); if (date_tmp) { - strftime (str_date_end, sizeof (str_date_end), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (str_date_end, sizeof (str_date_end), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + str_date_end[0] = '\0'; } } diff --git a/src/plugins/relay/relay-command.c b/src/plugins/relay/relay-command.c index 450187c3e..1f409dcdc 100644 --- a/src/plugins/relay/relay-command.c +++ b/src/plugins/relay/relay-command.c @@ -66,16 +66,18 @@ relay_command_client_list (int full) date_tmp = localtime (&(ptr_client->start_time)); if (date_tmp) { - strftime (date_start, sizeof (date_start), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (date_start, sizeof (date_start), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + date_start[0] = '\0'; } date_activity[0] = '\0'; date_tmp = localtime (&(ptr_client->last_activity)); if (date_tmp) { - strftime (date_activity, sizeof (date_activity), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (date_activity, sizeof (date_activity), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + date_activity[0] = '\0'; } if (full) @@ -156,8 +158,9 @@ relay_command_server_list () date_tmp = localtime (&(ptr_server->start_time)); if (date_tmp) { - strftime (date_start, sizeof (date_start), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (date_start, sizeof (date_start), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + date_start[0] = '\0'; } weechat_printf ( NULL, diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 361901b01..2d951c117 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -5462,7 +5462,10 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable) time = weechat_infolist_time (API_STR2PTR(c_infolist), c_variable); date_tmp = localtime (&time); if (date_tmp) - strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); + { + if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0) + timebuffer[0] = '\0'; + } result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/script/script-buffer.c b/src/plugins/script/script-buffer.c index 5c3dcd761..cfdada5f7 100644 --- a/src/plugins/script/script-buffer.c +++ b/src/plugins/script/script-buffer.c @@ -117,8 +117,9 @@ script_buffer_display_line_script (int line, struct t_script_repo *script) if (script->date_added > 0) { tm = localtime (&script->date_added); - strftime (str_date, sizeof (str_date), - "%Y-%m-%d", tm); + if (strftime (str_date, sizeof (str_date), + "%Y-%m-%d", tm) == 0) + str_date[0] = '\0'; snprintf (str_item, sizeof (str_item), "%s%s", weechat_color ( @@ -232,8 +233,9 @@ script_buffer_display_line_script (int line, struct t_script_repo *script) if (script->date_updated > 0) { tm = localtime (&script->date_updated); - strftime (str_date, sizeof (str_date), - "%Y-%m-%d", tm); + if (strftime (str_date, sizeof (str_date), + "%Y-%m-%d", tm) == 0) + str_date[0] = '\0'; snprintf (str_item, sizeof (str_item), "%s%s", weechat_color ( @@ -672,14 +674,16 @@ script_buffer_display_detail_script (struct t_script_repo *script) } line++; tm = localtime (&script->date_added); - strftime (str_time, sizeof (str_time), "%Y-%m-%d %H:%M:%S", tm); + if (strftime (str_time, sizeof (str_time), "%Y-%m-%d %H:%M:%S", tm) == 0) + str_time[0] = '\0'; weechat_printf_y (script_buffer, line + 1, "%s: %s", script_buffer_detail_label (_(labels[line]), max_length), str_time); line++; tm = localtime (&script->date_updated); - strftime (str_time, sizeof (str_time), "%Y-%m-%d %H:%M:%S", tm); + if (strftime (str_time, sizeof (str_time), "%Y-%m-%d %H:%M:%S", tm) == 0) + str_time[0] = '\0'; weechat_printf_y (script_buffer, line + 1, "%s: %s", script_buffer_detail_label (_(labels[line]), max_length), diff --git a/src/plugins/script/script-mouse.c b/src/plugins/script/script-mouse.c index 534331697..12eeac36b 100644 --- a/src/plugins/script/script-mouse.c +++ b/src/plugins/script/script-mouse.c @@ -98,10 +98,12 @@ script_mouse_focus_chat_cb (const void *pointer, void *data, weechat_hashtable_set (info, "script_md5sum", ptr_script->md5sum); weechat_hashtable_set (info, "script_url", ptr_script->url); tm = localtime (&ptr_script->date_added); - strftime (str_date, sizeof (str_date), "%Y-%m-%d %H:%M:%S", tm); + if (strftime (str_date, sizeof (str_date), "%Y-%m-%d %H:%M:%S", tm) == 0) + str_date[0] = '\0'; weechat_hashtable_set (info, "script_date_added", str_date); tm = localtime (&ptr_script->date_updated); - strftime (str_date, sizeof (str_date), "%Y-%m-%d %H:%M:%S", tm); + if (strftime (str_date, sizeof (str_date), "%Y-%m-%d %H:%M:%S", tm) == 0) + str_date[0] = '\0'; weechat_hashtable_set (info, "script_date_updated", str_date); weechat_hashtable_set (info, "script_version_loaded", ptr_script->version_loaded); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 28675b21e..aeffc60bc 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -4839,7 +4839,10 @@ API_FUNC(infolist_time) time = weechat_infolist_time (API_STR2PTR(infolist), variable); date_tmp = localtime (&time); if (date_tmp) - strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); + { + if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0) + timebuffer[0] = '\0'; + } result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c index 79b2955a9..6dfcc4e0f 100644 --- a/src/plugins/trigger/trigger-callback.c +++ b/src/plugins/trigger/trigger-callback.c @@ -798,7 +798,9 @@ trigger_callback_print_cb (const void *pointer, void *data, date_tmp = localtime (&date); if (date_tmp) { - strftime (str_temp, sizeof (str_temp), "%Y-%m-%d %H:%M:%S", date_tmp); + if (strftime (str_temp, sizeof (str_temp), + "%Y-%m-%d %H:%M:%S", date_tmp) == 0) + str_temp[0] = '\0'; weechat_hashtable_set (extra_vars, "tg_date", str_temp); } snprintf (str_temp, sizeof (str_temp), "%d", displayed); @@ -940,7 +942,9 @@ trigger_callback_timer_cb (const void *pointer, void *data, date_tmp = localtime (&date); if (date_tmp) { - strftime (str_temp, sizeof (str_temp), "%Y-%m-%d %H:%M:%S", date_tmp); + if (strftime (str_temp, sizeof (str_temp), + "%Y-%m-%d %H:%M:%S", date_tmp) == 0) + str_temp[0] = '\0'; weechat_hashtable_set (extra_vars, "tg_date", str_temp); } diff --git a/src/plugins/xfer/xfer-buffer.c b/src/plugins/xfer/xfer-buffer.c index 4cb89270f..a2a8eee97 100644 --- a/src/plugins/xfer/xfer-buffer.c +++ b/src/plugins/xfer/xfer-buffer.c @@ -148,8 +148,9 @@ xfer_buffer_refresh (const char *hotlist) date_tmp = localtime (&(ptr_xfer->start_time)); if (date_tmp) { - strftime (date, sizeof (date), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (date, sizeof (date), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + date[0] = '\0'; } weechat_printf_y (xfer_buffer, (line * 2) + 3, "%s%s%s %s%s%s%s%s", diff --git a/src/plugins/xfer/xfer-command.c b/src/plugins/xfer/xfer-command.c index 56a2de0fd..b4bc76ea4 100644 --- a/src/plugins/xfer/xfer-command.c +++ b/src/plugins/xfer/xfer-command.c @@ -134,8 +134,9 @@ xfer_command_xfer_list (int full) date_tmp = localtime (&(ptr_xfer->start_time)); if (date_tmp) { - strftime (date, sizeof (date), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (date, sizeof (date), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + date[0] = '\0'; } weechat_printf (NULL, /* TRANSLATORS: "%s" after "started on" is a date */ @@ -171,8 +172,9 @@ xfer_command_xfer_list (int full) date_tmp = localtime (&(ptr_xfer->start_transfer)); if (date_tmp) { - strftime (date, sizeof (date), - "%a, %d %b %Y %H:%M:%S", date_tmp); + if (strftime (date, sizeof (date), + "%a, %d %b %Y %H:%M:%S", date_tmp) == 0) + date[0] = '\0'; } weechat_printf (NULL, /* TRANSLATORS: "%s" after "started on" is a date */ |