# HG changeset patch # User aidan # Date 1187795419 0 # Node ID 1ce0622a56a31ed07d8e785bb0d91c7e20486129 # Parent db22824aa0205149b373021a0dd9e74c6e7251ac [xemacs-hg @ 2007-08-22 15:10:10 by aidan] Patch from Nix; fix buffer overrun in pdump_load() See 87y7r4lzwf.fsf@hades.wkstn.nix , also http://calypso.tux.org/pipermail/xemacs-patches/2006-October/000017.html for explanation diff -r db22824aa020 -r 1ce0622a56a3 src/ChangeLog --- a/src/ChangeLog Wed Aug 22 07:15:29 2007 +0000 +++ b/src/ChangeLog Wed Aug 22 15:10:19 2007 +0000 @@ -1,3 +1,9 @@ +2006-10-26 Nix + + * dumper.c (pdump_load): Statically allocate a large enough + exe_path for all conceivable uses. Fixes a buffer overrun. + * text.h (MAX_XETCHAR_SIZE): Define, for PATH_MAX_EXTERNAL. + 2007-08-21 Aidan Kehoe * mule-ccl.c (ccl_driver): diff -r db22824aa020 -r 1ce0622a56a3 src/dumper.c --- a/src/dumper.c Wed Aug 22 07:15:29 2007 +0000 +++ b/src/dumper.c Wed Aug 22 15:10:19 2007 +0000 @@ -2659,7 +2659,7 @@ wext_strcpy (exe_path, wexe); } #else /* !WIN32_NATIVE */ - Wexttext *exe_path; + Wexttext exe_path[PATH_MAX_EXTERNAL]; Wexttext *w; const Wexttext *dir, *p; @@ -2693,8 +2693,7 @@ if (p != dir) { /* invocation-name includes a directory component -- presumably it - is relative to cwd, not $PATH */ - exe_path = alloca_array (Wexttext, 1 + wext_strlen (dir)); + is relative to cwd, not $PATH. */ wext_strcpy (exe_path, dir); } else @@ -2702,9 +2701,6 @@ const Wexttext *path = wext_getenv ("PATH"); /* not egetenv -- not yet init. */ const Wexttext *name = p; - exe_path = alloca_array (Wexttext, - 10 + max (wext_strlen (name), - wext_strlen (path))); for (;;) { p = path; diff -r db22824aa020 -r 1ce0622a56a3 src/text.h --- a/src/text.h Wed Aug 22 07:15:29 2007 +0000 +++ b/src/text.h Wed Aug 22 15:10:19 2007 +0000 @@ -2988,6 +2988,7 @@ /* Extra indirection needed in case of manifest constant as arg */ #define WEXTSTRING_1(arg) L##arg #define WEXTSTRING(arg) WEXTSTRING_1(arg) +#define MAX_XETCHAR_SIZE sizeof (WCHAR) #define wext_strlen wcslen #define wext_strcmp wcscmp #define wext_strncmp wcsncmp @@ -3013,6 +3014,7 @@ #else #define WEXTTEXT_ZTERM_SIZE sizeof (char) #define WEXTSTRING(arg) arg +#define MAX_XETCHAR_SIZE sizeof (char) #define wext_strlen strlen #define wext_strcmp strcmp #define wext_strncmp strncmp