Index: filter.c
===================================================================
--- filter.c	(revision 601733df0126729fcd095240a5ef18b057830617)
+++ filter.c	(revision 0504f6318cdf8fe825d6783bd0909a68afded8bb)
@@ -212,36 +212,36 @@
 
 
-void owl_filter_print(owl_filter *f, char *out)
-{
-  strcpy(out, owl_filter_get_name(f));
-  strcat(out, ": ");
+char* owl_filter_print(owl_filter *f)
+{
+  GString *out = g_string_new(owl_filter_get_name(f));
+
+  g_string_append(out, ": ");
 
   if (f->fgcolor!=OWL_COLOR_DEFAULT) {
-    strcat(out, "-c ");
+    g_string_append(out, "-c ");
     if (f->fgcolor < 8) {
-      strcat(out, owl_util_color_to_string(f->fgcolor));
+      g_string_append(out, owl_util_color_to_string(f->fgcolor));
     }
     else {
-      char* c = owl_sprintf("%i",f->fgcolor);
-      strcat(out, c);
-      owl_free(c);
-    }
-    strcat(out, " ");
+      g_string_append_printf(out, "%i",f->fgcolor);
+    }
+    g_string_append(out, " ");
   }
   if (f->bgcolor!=OWL_COLOR_DEFAULT) {
-    strcat(out, "-b ");
+    g_string_append(out, "-b ");
     if (f->bgcolor < 8) {
-      strcat(out, owl_util_color_to_string(f->bgcolor));
+      g_string_append(out, owl_util_color_to_string(f->bgcolor));
     }
     else {
-      char* c = owl_sprintf("%i",f->bgcolor);
-      strcat(out, c);
-      owl_free(c);
-    }
-    strcat(out, " ");
-  }
-  if(!f->root) return;
-  owl_filterelement_print(f->root, out);
-  strcat(out, "\n");
+      g_string_append_printf(out, "%i",f->fgcolor);
+    }
+    g_string_append(out, " ");
+  }
+  if(f->root) {
+    owl_filterelement_print(f->root, out);
+    g_string_append(out, "\n");
+  }
+
+  return g_string_free(out, 0);
 }
 
@@ -249,11 +249,16 @@
 int owl_filter_equiv(owl_filter *a, owl_filter *b)
 {
-  char buff[LINE], buff2[LINE];
-
-  owl_filter_print(a, buff);
-  owl_filter_print(b, buff2);
-
-  if (!strcmp(buff, buff2)) return(1);
-  return(0);
+  char *buffa, *buffb;
+  int ret;
+
+  buffa = owl_filter_print(a);
+  buffb = owl_filter_print(b);
+
+  ret = !strcmp(buffa, buffb);
+
+  owl_free(buffa);
+  owl_free(buffb);
+
+  return ret;
 }
 
Index: filterelement.c
===================================================================
--- filterelement.c	(revision 81655f8c44b634198f4f03d1fd96fbbd6f8a6717)
+++ filterelement.c	(revision 0504f6318cdf8fe825d6783bd0909a68afded8bb)
@@ -126,63 +126,63 @@
 /* Print methods */
 
-static void owl_filterelement_print_true(owl_filterelement *fe, char *buf)
-{
-  strcat(buf, "true");
-}
-
-static void owl_filterelement_print_false(owl_filterelement *fe, char *buf)
-{
-  strcat(buf, "false");
-}
-
-static void owl_filterelement_print_re(owl_filterelement *fe, char *buf)
+static void owl_filterelement_print_true(owl_filterelement *fe, GString *buf)
+{
+  g_string_append(buf, "true");
+}
+
+static void owl_filterelement_print_false(owl_filterelement *fe, GString *buf)
+{
+  g_string_append(buf, "false");
+}
+
+static void owl_filterelement_print_re(owl_filterelement *fe, GString *buf)
 {
   char *re, *q;
-  strcat(buf, fe->field);
-  strcat(buf, " ");
+  g_string_append(buf, fe->field);
+  g_string_append(buf, " ");
 
   re = owl_regex_get_string(&(fe->re));
   q = owl_getquoting(re);
-  strcat(buf, q);
-  strcat(buf, re); 
-  strcat(buf, q);
-}
-
-static void owl_filterelement_print_filter(owl_filterelement *fe, char *buf)
-{
-  strcat(buf, "filter ");
-  strcat(buf, fe->field);
-}
-
-static void owl_filterelement_print_perl(owl_filterelement *fe, char *buf)
-{
-  strcat(buf, "perl ");
-  strcat(buf, fe->field);
-}
-
-static void owl_filterelement_print_group(owl_filterelement *fe, char *buf)
-{
-  strcat(buf, "( ");
+  g_string_append(buf, q);
+  g_string_append(buf, re);
+  g_string_append(buf, q);
+}
+
+static void owl_filterelement_print_filter(owl_filterelement *fe, GString *buf)
+{
+  g_string_append(buf, "filter ");
+  g_string_append(buf, fe->field);
+}
+
+static void owl_filterelement_print_perl(owl_filterelement *fe, GString *buf)
+{
+  g_string_append(buf, "perl ");
+  g_string_append(buf, fe->field);
+}
+
+static void owl_filterelement_print_group(owl_filterelement *fe, GString *buf)
+{
+  g_string_append(buf, "( ");
   owl_filterelement_print(fe->left, buf) ;
-  strcat(buf, " )");
-}
-
-static void owl_filterelement_print_or(owl_filterelement *fe, char *buf)
+  g_string_append(buf, " )");
+}
+
+static void owl_filterelement_print_or(owl_filterelement *fe, GString *buf)
 {
   owl_filterelement_print(fe->left, buf);
-  strcat(buf, " or ");
+  g_string_append(buf, " or ");
   owl_filterelement_print(fe->right, buf);
 }
 
-static void owl_filterelement_print_and(owl_filterelement *fe, char *buf)
+static void owl_filterelement_print_and(owl_filterelement *fe, GString *buf)
 {
   owl_filterelement_print(fe->left, buf);
-  strcat(buf, " and ");
+  g_string_append(buf, " and ");
   owl_filterelement_print(fe->right, buf);
 }
 
-static void owl_filterelement_print_not(owl_filterelement *fe, char *buf)
-{
-  strcat(buf, " not ");
+static void owl_filterelement_print_not(owl_filterelement *fe, GString *buf)
+{
+  g_string_append(buf, " not ");
   owl_filterelement_print(fe->left, buf);
 }
@@ -321,5 +321,5 @@
 }
 
-void owl_filterelement_print(owl_filterelement *fe, char *buf)
+void owl_filterelement_print(owl_filterelement *fe, GString *buf)
 {
   if(!fe || !fe->print_elt) return;
Index: functions.c
===================================================================
--- functions.c	(revision d81f8d043bdcfef14b96da5b8295b6bd13c164d5)
+++ functions.c	(revision 0504f6318cdf8fe825d6783bd0909a68afded8bb)
@@ -2515,5 +2515,5 @@
 {
   owl_filter *f;
-  char buff[5000];
+  char *buff;
 
   f=owl_global_get_filter(&g, name);
@@ -2522,6 +2522,7 @@
     return;
   }
-  owl_filter_print(f, buff);
+  buff = owl_filter_print(f);
   owl_function_popless_text(buff);
+  owl_free(buff);
 }
 
@@ -2531,4 +2532,5 @@
   owl_list *fl;
   char buff[5000];
+  char *tmp;
   owl_fmtext fm;
   int i, j;
@@ -2544,5 +2546,7 @@
     snprintf(buff, sizeof(buff), "[% 2d] ", i+1);
     owl_fmtext_append_normal(&fm, buff);
-    owl_filter_print(f, buff);
+    tmp = owl_filter_print(f);
+    owl_fmtext_append_normal(&fm, tmp);
+    owl_free(tmp);
     owl_fmtext_append_normal(&fm, buff);
   }
Index: owl.h
===================================================================
--- owl.h	(revision 731dd1eae56c676c26e76bfa6f93f649afb529ab)
+++ owl.h	(revision 0504f6318cdf8fe825d6783bd0909a68afded8bb)
@@ -406,5 +406,5 @@
   int (*match_message)(struct _owl_filterelement *fe, owl_message *m);
   /* Append a string representation of the filterelement onto buf*/
-  void (*print_elt)(struct _owl_filterelement *fe, char * buf);
+  void (*print_elt)(struct _owl_filterelement *fe, GString *buf);
   /* Operands for and,or,not*/
   struct _owl_filterelement *left, *right;
