[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mutt-dev
Subject:    PATCH complete.c
From:       Edmund GRIMLEY EVANS <edmundo () rano ! org>
Date:       2000-08-27 11:46:18
[Download RAW message or body]

This patch seems to stop some segmentation faults from happening. (I
got one at enter.c:512 when playing with some long file names.)

Of course, using strfcpy everywhere might stop it from segmenting, but
Mutt still produces syntactically incorrect messages because of data
having been silently truncated. Personally I hate fixed-length buffers
and prefer to use malloc.

Edmund


--- mutt.orig/complete.c	Fri Jun 16 19:02:05 2000
+++ mutt/complete.c	Sun Aug 27 12:21:11 2000
@@ -176,13 +176,14 @@
 	if (dirpart[0])
 	{
 	  strfcpy (buf, exp_dirpart, sizeof (buf));
-	  strcat (buf, "/");
+	  strfcpy (buf + strlen (buf), "/", sizeof (buf) - strlen (buf));
 	}
 	else
 	  buf[0] = 0;
-	strcat (buf, filepart);
+	strfcpy (buf + strlen (buf), filepart, sizeof (buf) - strlen (buf));
 	if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR))
-	  strcat (filepart, "/");
+	  strfcpy (filepart + strlen (filepart), "/",
+		   sizeof (filepart) - strlen (filepart));
 	init = 1;
       }
     }
@@ -191,13 +192,13 @@
 
   if (dirpart[0])
   {
-    strcpy (s, dirpart);
+    strfcpy (s, dirpart, slen);
     if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+')
-      strcat (s, "/");
-    strcat (s, filepart);
+      strfcpy (s + strlen (s), "/", slen - strlen (s));
+    strfcpy (s + strlen (s), filepart, slen - strlen (s));
   }
   else
-    strcpy (s, filepart);
+    strfcpy (s, filepart, slen);
 
   return (init ? 0 : -1);
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic