Index: lpe-1.2.7/src/buffer.c
===================================================================
--- lpe-1.2.7.orig/src/buffer.c	2005-10-25 15:46:53.000000000 -0500
+++ lpe-1.2.7/src/buffer.c	2014-12-23 09:08:54.888625050 -0600
@@ -56,7 +56,6 @@
 set_buf_mode (buffer * buf, char *reqname)
 {
     DIR *dir;
-    char name[PATH_MAX];
     char *pathpos, *nextcolon;
     void *handle = NULL;
     int found;
@@ -86,40 +85,53 @@
 
     do
     {
-	char *basename;
+        char *name = NULL;
 	struct dirent *ent;
 
 	if (*pathpos == '~')
 	{
 	    char *home = getenv ("HOME");
 
-	    strcpy (name, (home == NULL) ? "/" : home);
+            if (home == NULL)
+                name = strdup("/");
+            else
+                name = strdup(home);
 	    pathpos++;
 	} else
-	    name[0] = '\0';
+	    name = strdup("");
 
 	nextcolon = strchr (pathpos, ':');
 
 	if (nextcolon != NULL)
 	{
+	    int len = (nextcolon - pathpos) + strlen(name) + 2 + 8;
+	    name = realloc(name, len);
 	    strncat (name, pathpos, nextcolon - pathpos);
-	    pathpos += nextcolon - pathpos + 1;
-	} else
-	    strcpy (name, pathpos);
+	    name[len-2-8] = '\0';
+	    pathpos += (nextcolon - pathpos) + 1;
+	}
+	else
+	{
+	    int len = strlen(pathpos) + strlen(name) + 2 + 8;
+	    name = realloc(name, len);
+	    strcat (name, pathpos);
+	}
 
-	basename = name + strlen (name);
-	if (*(basename - 1) != '/')
+	if (name[strlen(name)-1] != '/')
 	{
-	    *(basename++) = '/';
-	    *basename = '\0';
+            int pos = strlen(name);
+            name[pos++] = '/';
+            name[pos] = '\0';
 	}
 
 	if (reqname != NULL)
 	{
 	    struct stat st;
 
-	    strcpy (basename, reqname);
-	    strcat (basename, ".so");
+            name = realloc(name, strlen(name) + strlen(reqname) + 3 + 1);
+	    strcat (name, reqname);
+	    strcat (name, ".so");
+
 	    stat (name, &st);
 
 	    if (S_ISREG (st.st_mode))
@@ -129,17 +141,27 @@
 		    found = 1;
 	    }
 
-	} else
+	}
+	else
 	{
 	    dir = opendir (name);
 	    if (dir == NULL)
 		continue;
 
+            int basename_len = 0;
+            int basename_off = strlen(name);
+            char *basename = name + basename_off;
+
 	    while ((!found) && ((ent = readdir (dir)) != NULL))
 	    {
 		struct stat st;
 		int (*accept) (buffer *);
 
+                if (strlen(ent->d_name) > basename_len) {
+                    basename_len = strlen(ent->d_name);
+                    name = realloc(name, (basename-name) + basename_len + 1);
+                    basename = name + basename_off;
+                }
 		strcpy (basename, ent->d_name);
 		stat (name, &st);
 
@@ -161,6 +183,8 @@
 	    }
 	    closedir (dir);
 	}
+
+	free(name);
     }
     while ((!found) && (nextcolon != NULL));
 
@@ -482,8 +506,7 @@
 
     if (fname != NULL)
     {
-        buf->fname = calloc(100, sizeof(char));
-        strcpy(buf->fname, fname);
+        buf->fname = strdup(fname);
         buf->name = strrchr (buf->fname, '/');
         if (buf->name == NULL)
 	    buf->name = buf->fname;
Index: lpe-1.2.7/src/minibuf.c
===================================================================
--- lpe-1.2.7.orig/src/minibuf.c	2014-06-23 15:34:32.405569090 -0500
+++ lpe-1.2.7/src/minibuf.c	2014-06-23 18:15:58.453945670 -0500
@@ -135,7 +135,6 @@
     struct dirent *de;
 
     char **am;
-    char pn[PATH_MAX];
     char *path, *nc, *mn;
 
     int nl;
@@ -155,24 +154,35 @@
 
     do
     {
+        char *pn = NULL;
+
 	if (*path == '~')
 	{
 	    char *home = getenv ("HOME");
-	    strcpy (pn, (home != NULL ? home : "/"));
+	    if (home != NULL)
+	        pn = strdup(home);
+	    else
+	        pn = strdup("/");
 	    path++;
-	} else
+	}
+	else
 	{
-	    *pn = '\0';
+	    pn = strdup("");
 	}
 
 	nc = strchr (path, ':');
 
 	if (nc != NULL)
 	{
+	    int len = (nc - path) + strlen(pn) + 1;
+	    pn = realloc(pn, len);
 	    strncat (pn, path, nc - path);
+	    pn[len-1] = 0;
 	    path += nc - path + 1;
 	} else
 	{
+	    int len = strlen(path) + strlen(pn) + 1;
+	    pn = realloc(pn, len);
 	    strcat (pn, path);
 	}
 
@@ -206,6 +216,8 @@
 	    }
 	    closedir (dir);
 	}
+
+	free (pn);
     }
     while (nc != 0);
 
Index: lpe-1.2.7/src/lpe.h
===================================================================
--- lpe-1.2.7.orig/src/lpe.h	2014-06-23 15:33:39.001567013 -0500
+++ lpe-1.2.7/src/lpe.h	2014-06-23 15:36:43.577574189 -0500
@@ -11,17 +11,6 @@
 
 #include "i18n.h"
 
-/*
- * This is bad. very bad. but I need PATH_MAX for -pedantic -ansi.
- * It is defined in linux/limits.h, but that's Linux only, and I
- * don't have access to other systems, so can't detect it in
- * configure...
- *  - Gergely Nagy
- */
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#endif
-
 /* Flag to quit the application */
 extern int quit;
 
