From f11af8a48cfef05314e6e5d86e18861cffbde9f1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 22 Sep 2014 17:37:22 +0300 Subject: [PATCH] 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. --- src/ChangeLog | 6 ++++++ src/fileio.c | 3 +++ 2 files changed, 9 insertions(+) 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 -- 2.39.5