diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2016-02-16 10:19:57 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2016-02-16 10:19:57 +0100 |
commit | 64ef7e8621c2d555735b4667ab39cfbb261422ff (patch) | |
tree | 7c44bbd92bbbb580348f76a009ee7f5261332243 /src | |
parent | 0e6a6a0334ed3edd3b8ed722724a63f5fe38471c (diff) | |
download | weechat-64ef7e8621c2d555735b4667ab39cfbb261422ff.zip |
core: fix truncation of buffer names in hotlist (closes #668)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui-bar-item.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 5b2eedb22..b45987ae3 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -1311,8 +1311,8 @@ gui_bar_item_hotlist_cb (void *data, struct t_gui_bar_item *item, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) { - char str_hotlist[4096], format[32], *buffer_without_name_displayed; - const char *hotlist_suffix; + char str_hotlist[4096], *buffer_without_name_displayed, *buffer_name; + const char *hotlist_suffix, *ptr_buffer_name; struct t_gui_hotlist *ptr_hotlist; int numbers_count, names_count, display_name, count_max; int priority, priority_min, priority_min_displayed, private; @@ -1417,19 +1417,25 @@ gui_bar_item_hotlist_cb (void *data, struct t_gui_bar_item *item, strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_DELIM); strcat (str_hotlist, ":"); strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_FG); + ptr_buffer_name = (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ? + gui_buffer_get_short_name (ptr_hotlist->buffer) : ptr_hotlist->buffer->name; if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0) { - snprintf (format, sizeof (format), "%%s"); + buffer_name = strdup (ptr_buffer_name); } else { - snprintf (format, sizeof (format), - "%%.%ds", - CONFIG_INTEGER(config_look_hotlist_names_length)); + buffer_name = utf8_strndup ( + ptr_buffer_name, + CONFIG_INTEGER(config_look_hotlist_names_length)); + } + if (buffer_name) + { + if (strlen (buffer_name) > 128) + buffer_name[128] = '\0'; + strcat (str_hotlist, buffer_name); + free (buffer_name); } - snprintf (str_hotlist + strlen (str_hotlist), 128, format, - (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ? - gui_buffer_get_short_name (ptr_hotlist->buffer) : ptr_hotlist->buffer->name); } else { |