X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/dacbc44ca3fc825c9e5ffa799f1a0937c1da0020..792b3d23233b65eebe5ceeacc635175372de5fca:/nt/cmdproxy.c diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c index 7d810e3365..e48ca63a25 100644 --- a/nt/cmdproxy.c +++ b/nt/cmdproxy.c @@ -1,5 +1,5 @@ /* Proxy shell designed for use with Emacs on Windows 95 and NT. - Copyright (C) 1997, 2001-2013 Free Software Foundation, Inc. + Copyright (C) 1997, 2001-2014 Free Software Foundation, Inc. Accepts subset of Unix sh(1) command-line options, for compatibility with elisp code written for Unix. When possible, executes external @@ -292,11 +292,15 @@ make_absolute (const char *prog) while (*path) { + size_t len; + /* Get next directory from path. */ p = path; while (*p && *p != ';') p++; - strncpy (dir, path, p - path); - dir[p - path] = '\0'; + /* A broken PATH could have too long directory names in it. */ + len = min (p - path, sizeof (dir) - 1); + strncpy (dir, path, len); + dir[len] = '\0'; /* Search the directory for the program. */ if (search_dir (dir, prog, MAX_PATH, absname) > 0) @@ -319,7 +323,7 @@ try_dequote_cmdline (char* cmdline) /* Dequoting can only subtract characters, so the length of the original command line is a bound on the amount of scratch space we need. This length, in turn, is bounded by the 32k - CreateProces limit. */ + CreateProcess limit. */ char * old_pos = cmdline; char * new_cmdline = alloca (strlen(cmdline)); char * new_pos = new_cmdline; @@ -843,4 +847,3 @@ main (int argc, char ** argv) return 0; } -