From: Eli Zaretskii Date: Mon, 22 Sep 2014 14:37:22 +0000 (+0300) Subject: Fix bug #18516 with SIGSEGV in expand-file-name. X-Git-Tag: emacs-25.0.90~2635^2~679^2~253 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f11af8a48cfef05314e6e5d86e18861cffbde9f1;p=emacs.git Fix bug #18516 with SIGSEGV in expand-file-name. 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index b7858c609b4..5aad2f91834 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-09-22 Eli Zaretskii + + * 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 Avoid extra call to oblookup when interning symbols. diff --git a/src/fileio.c b/src/fileio.c index 80905c63d3a..13e2c889020 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -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