]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #18516 with SIGSEGV in expand-file-name.
authorEli Zaretskii <eliz@gnu.org>
Mon, 22 Sep 2014 14:37:22 +0000 (17:37 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 22 Sep 2014 14:37:22 +0000 (17:37 +0300)
 src/fileio.c (Fexpand_file_name) [DOS_NT]: Make sure newdirlim is
 always set to a valid value.  Make sure the size passed to alloca
 is always positive.

src/ChangeLog
src/fileio.c

index b7858c609b49b60032aedbdb86f1455a96e9e56a..5aad2f91834b6fd000bd001361288041245e4de4 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-22  Eli Zaretskii  <eliz@gnu.org>
+
+       * fileio.c (Fexpand_file_name) [DOS_NT]: Make sure newdirlim is
+       always set to a valid value.  Make sure the size passed to alloca
+       is always positive.  (Bug#18516)
+
 2014-09-22  Dmitry Antipov  <dmantipov@yandex.ru>
 
        Avoid extra call to oblookup when interning symbols.
index 80905c63d3a2acd8d047a00710ce507ee23c5b46..13e2c889020144b7ec70c2982bd25e6ab8594bc9 100644 (file)
@@ -1237,6 +1237,8 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
              newdirlim = adir + SBYTES (tem);
              memcpy (adir, SSDATA (tem), SBYTES (tem) + 1);
            }
+         else
+           newdirlim = adir + strlen (adir);
        }
       if (!adir)
        {
@@ -1383,6 +1385,7 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
 
   /* Now concatenate the directory and name to new space in the stack frame.  */
   tlen = length + file_name_as_directory_slop + (nmlim - nm) + 1;
+  eassert (tlen > file_name_as_directory_slop + 1);
 #ifdef DOS_NT
   /* Reserve space for drive specifier and escape prefix, since either
      or both may need to be inserted.  (The Microsoft x86 compiler