changeset: 6671:fc33b34d637b
user:      Richard Russon <[email protected]>
date:      Tue Jun 07 13:40:04 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/fc33b34d637b

Setting $sidebar_width to more than 128 would cause bad things to happen.

First, give the users more than enough space.
Second, don't pad out short strings beyond the buffer

---
 sidebar.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 9937540dab42 -r fc33b34d637b sidebar.c
--- a/sidebar.c Tue Jun 07 13:27:45 2016 -0700
+++ b/sidebar.c Tue Jun 07 13:40:04 2016 -0700
@@ -46,7 +46,7 @@
  */
 struct sidebar_entry
 {
-  char         box[SHORT_STRING];
+  char         box[STRING];
   BUFFY       *buffy;
 };
 
@@ -137,7 +137,7 @@
 {
   struct sidebar_entry *sbe = (struct sidebar_entry *) data;
   unsigned int optional;
-  char fmt[SHORT_STRING], buf[SHORT_STRING];
+  char fmt[STRING];
 
   if (!sbe || !dest)
     return src;
@@ -227,8 +227,8 @@
         mutt_format_s (dest, destlen, prefix, "!!");
       else
       {
-        snprintf (buf, sizeof (buf), "%d!", b->msg_flagged);
-        mutt_format_s (dest, destlen, prefix, buf);
+        snprintf (fmt, sizeof (fmt), "%d!", b->msg_flagged);
+        mutt_format_s (dest, destlen, prefix, fmt);
       }
       break;
   }
@@ -270,6 +270,7 @@
   /* Force string to be exactly the right width */
   int w = mutt_strwidth (buf);
   int s = strlen (buf);
+  width = MIN(buflen, width);
   if (w < width)
   {
     /* Pad with spaces */
@@ -704,7 +705,7 @@
         safe_strcat (sidebar_folder_name, sfn_len, tmp_folder_name);
       }
     }
-    char str[SHORT_STRING];
+    char str[STRING];
     make_sidebar_entry (str, sizeof (str), w, sidebar_folder_name, b);
     printw ("%s", str);
     if (sidebar_folder_depth > 0)

Reply via email to