diff --git a/ChangeLog b/ChangeLog
index a79f2de7db234dd6db5ae3dad315dc3306ca3c8c..41bb6ff6b8c8642652f83497789d9f6655255fcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@ CVS code -
 General
 	- Added --disable-help option, affects acconfig.h, configure(.in),
 	  winio.c:do_help, nano.c:help_init,help_text_init.
+	- Changed filename to no longer use PATH_MAX, so it can work on the
+	  HURD.  Changes in files.c:write_file(), new function
+	  nano.c:clear_filename(), many changed in main(), a few other
+	  places.  Please test this!
 - cut.c:
   do_uncut_text()
 	- Fix renumbering bug when uncutting marked test at filebot.
@@ -14,8 +18,6 @@ General
 	- Change open call flags, basically copy joe's way of doing it so
 	  a more recent version will actually be included in (un)stable.
 	- Remove useless fstat call.
-	- Use MAX_PATH instead of static 132 for strncpy, at least until
-	  we no longer use MAX_PATH.
   open_file()
 	- Added check for S_ISBLK and S_ISCHR, don't open device files!
 - nano.c:
diff --git a/files.c b/files.c
index 4f556a35a93e6fd3224c642ec4b38b3b9ec3ae70..18f65211e5e7a6b17a63004b76f10f42ddd23642 100644
--- a/files.c
+++ b/files.c
@@ -306,7 +306,7 @@ int do_insertfile(void)
 int write_file(char *name, int tmp)
 {
     long size, lineswritten = 0;
-    char buf[PATH_MAX + 1];
+    static char *buf = NULL;
     filestruct *fileptr;
     int fd, mask = 0, realexists, anyexists;
     struct stat st, lst;
@@ -322,6 +322,9 @@ int write_file(char *name, int tmp)
     if (realname != NULL)
 	free(realname);
 
+    if (buf != NULL)
+	free(buf);
+
 #ifndef DISABLE_TABCOMP
     realname = real_dir_from_tilde(name);
 #else
@@ -365,13 +368,8 @@ int write_file(char *name, int tmp)
     }
     /* Don't follow symlink.  Create new file. */
     else {
-	if (strlen(realname) > (PATH_MAX - 7)) {
-	    statusbar(_("Could not open file: Path length exceeded."));
-	    return -1;
-	}
-
-	memset(buf, 0x00, PATH_MAX + 1);
-	strcat(buf, realname);
+	buf = nmalloc(strlen(realname) + 8);
+	strncpy(buf, realname, strlen(realname)+1);
 	strcat(buf, ".XXXXXX");
 	if ((fd = mkstemp(buf)) == -1) {
 	    if (ISSET(TEMP_OPT)) {
@@ -472,7 +470,7 @@ int write_file(char *name, int tmp)
 		  mask, realname, strerror(errno));
 
     if (!tmp) {
-	strncpy(filename, realname, PATH_MAX - 1);
+	filename = mallocstrcpy(filename, realname);
 	statusbar(_("Wrote %d lines"), lineswritten);
 	UNSET(MODIFIED);
 	titlebar();
diff --git a/global.c b/global.c
index 6366cf294f454ff23360433f35065707e208c0ef..b7c6773b5ec7dfd1984afdee428d5ba68caf7c9a 100644
--- a/global.c
+++ b/global.c
@@ -39,7 +39,7 @@ int center_x = 0, center_y = 0;	/* Center of screen */
 WINDOW *edit;			/* The file portion of the editor  */
 WINDOW *topwin;			/* Top line of screen */
 WINDOW *bottomwin;		/* Bottom buffer */
-char filename[PATH_MAX];	/* Name of the file */
+char *filename = NULL;		/* Name of the file */
 int editwinrows = 0;		/* How many rows long is the edit
 				   window? */
 filestruct *current;		/* Current buffer pointer */
diff --git a/nano.c b/nano.c
index 89110e9405a9625e9c4e0cb280cc641de1674d88..12e3ba4c8061ce945406bc0c2b2b13ddc723ed3d 100644
--- a/nano.c
+++ b/nano.c
@@ -146,6 +146,13 @@ void print_view_warning(void)
     statusbar(_("Key illegal in VIEW mode"));
 }
 
+void clear_filename(void)
+{
+    if (filename != NULL)
+	free(filename);
+    filename = nmalloc(1);
+    filename[0] = 0;
+}
 
 /* Initialize global variables - no better way for now */
 void global_init(void)
@@ -2161,19 +2168,19 @@ int main(int argc, char *argv[])
     /* See if there's a non-option in argv (first non-option is the
        filename, if +LINE is not given) */
     if (argc == 1 || argc <= optind)
-	strcpy(filename, "");
+	clear_filename();
     else {
 	/* Look for the +line flag... */
 	if (argv[optind][0] == '+') {
 	    startline = atoi(&argv[optind][1]);
 	    optind++;
 	    if (argc == 1 || argc <= optind)
-		strcpy(filename, "");
+		clear_filename();
 	    else
-		strncpy(filename, argv[optind], 132);
-	} else
-	    strncpy(filename, argv[optind], 132);
+		filename = mallocstrcpy(filename, argv[optind]);
 
+	} else
+	    filename = mallocstrcpy(filename, argv[optind]);
     }
 
 
diff --git a/proto.h b/proto.h
index fe22fea2998221b3e0b386781a1c9a3e0e420b76..22f91b7d0a3e627be57bd7ed1bdc91b6ff328306 100644
--- a/proto.h
+++ b/proto.h
@@ -38,7 +38,7 @@ extern int fill, flags,tabsize;
 extern int search_last_line;
 
 extern WINDOW *edit, *topwin, *bottomwin;
-extern char filename[PATH_MAX];
+extern char *filename;
 extern char *answer;
 extern char *hblank, *help_text;
 extern char *last_search;