From xemacs-m  Thu Sep 25 22:37:15 1997
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id WAA13793
	for <xemacs-beta@xemacs.org>; Thu, 25 Sep 1997 22:37:12 -0500 (CDT)
Received: (from steve@localhost)
	by altair.xemacs.org (8.8.7/8.8.7) id UAA04454;
	Thu, 25 Sep 1997 20:43:18 -0700
Mail-Copies-To: never
To: xemacs-beta@xemacs.org
Subject: Quick and dirty patch for directory-files core dump (v19 only)
X-Face: (:YAD@JS'&Kz'M}n7eX7gEvPR6U1mJ-kt;asEc2qAv;h{Yw7ckz<7+X_SYeTNAaPui:e~x$
 ,A=gkt*>UPL/}\a/#C~v2%ETiAY_sx;xve0yL??JWTtX_-NUzXyP38UdW#cmN1\4(X!c3m#%IbtB-3
 Z-!xpZi!`E.s{(;aP=b11"!3wQu]1j@^V|;n=B|{l<bZV1.AI`zWV%kPCnUhcgEe\(}/_kNd6,*3ZJ
 Q3o<YQ3^u;7jS=:p0--u3msQO
X-Attribution: sb
From: SL Baur <steve@xemacs.org>
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: text/plain; charset=US-ASCII
Date: 25 Sep 1997 20:43:17 -0700
Message-ID: <m2iuvopwoa.fsf@altair.xemacs.org>
Lines: 81
X-Mailer: Quassia Gnus v0.10/XEmacs 20.3(beta24) - "Ljubljana"

Will this do it for 19.16?

Index: src/dired.c
===================================================================
RCS file: /usr/local/xemacs/xemacs-19/src/dired.c,v
retrieving revision 1.6
diff -u -r1.6 dired.c
--- src/dired.c	1997/08/21 06:24:32	1.6
+++ src/dired.c	1997/09/26 03:20:59
@@ -58,16 +58,17 @@
   Bytecount dirname_length;
   Lisp_Object list, name, dirfilename = Qnil;
   Lisp_Object handler;
+  Lisp_Object errstring;
   struct re_pattern_buffer *bufp;
 
-  char statbuf [MAXNAMLEN+2];
+  char statbuf [4096];			/* BOGUS -- fixed in 20.3 */
   char *statbuf_tail;
   Lisp_Object tail_cons = Qnil;
-  char slashfilename[MAXNAMLEN+2];
+  char slashfilename[4096];		/* BOGUS -- fixed in 20.3 */
   char *filename = slashfilename;
 
-  struct gcpro gcpro1, gcpro2, gcpro3;
-  GCPRO3 (dirname, dirfilename, tail_cons);
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
+  GCPRO4 (dirname, dirfilename, tail_cons, errstring);
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -92,6 +93,10 @@
     /* XEmacs: this should come before the opendir() because it might error. */
     Lisp_Object name_as_dir = Ffile_name_as_directory (dirname);
     CHECK_STRING (name_as_dir);
+    if (XSTRING_LENGTH(name_as_dir) >= sizeof (statbuf))
+      {
+	report_file_error("Directory name too long", list1(name_as_dir));
+      }
     memcpy (statbuf, ((char *) XSTRING_DATA (name_as_dir)),
            XSTRING_LENGTH (name_as_dir));
     statbuf_tail = statbuf + XSTRING_LENGTH (name_as_dir);
@@ -136,6 +141,11 @@
   if (dirname_length == 0
       || !IS_ANY_SEP (XSTRING_BYTE (dirname, dirname_length - 1)))
   {
+    if ((filename - slashfilename) >= (sizeof (slashfilename) - 1))
+      {
+	errstring = make_string(statbuf, 255);
+	report_file_error("Directory name too long", list1(errstring));
+      }
     *filename++ = DIRECTORY_SEP;
     dirname_length++;
   }
@@ -153,6 +163,12 @@
 	{
 	  int result;
 	  Lisp_Object oinhibit_quit = Vinhibit_quit;
+	  if (((filename - slashfilename) + len) >=
+	      (sizeof (slashfilename) - 1))
+	    {
+	      errstring = make_string(slashfilename, 255);
+	      report_file_error("Directory name too long", list1(errstring));
+	    }
 	  strncpy (filename, dp->d_name, len);
 	  filename[len] = 0;
 	  /* re_search can now QUIT, so prevent it to avoid
@@ -168,6 +184,13 @@
 		  int dir_p;
 		  struct stat st;
 
+		  if (((statbuf_tail - statbuf) + len) >=
+		      (sizeof (statbuf) - 1))
+		    {
+		      errstring = make_string(statbuf, 255);
+		      report_file_error("Directory name too long",
+					list1(errstring));
+		    }
 		  memcpy (statbuf_tail, filename, len);
 		  statbuf_tail [len] = 0;
 

