Skip to content

Commit

Permalink
arg_heuristic(): be better prepared to handle path lists
Browse files Browse the repository at this point in the history
If we were to handle only single paths, the buffer really would only
need to fit a single one, but arg_heuristic is also used to convert e.g.
INFO_PATH and MAN_PATH (which can contain multiple absolute POSIX-style
paths that need to be converted to Windows-style paths).

This is only really relevant if the POSIX root directory's path is
already pretty long. Such a beast has been spotted in the wild, in the
Git for Windows project:

	git-for-windows/git#303

Of course, this patch is only a work-around that helps in many, but not
all cases. Obviously this patch will wait patiently until a real fix
comes around the corner, and then readily retire.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 14, 2017
1 parent c0e5eb3 commit 0d95620
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion winsup/cygwin/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,9 @@ arg_heuristic_with_exclusions (char const * const arg, char const * exclusions,
exclusions += strlen (exclusions) + 1;
}

size_t stack_len = arglen + MAX_PATH;
// Leave enough room for at least 16 path elements; we might be converting
// a path list.
size_t stack_len = arglen + 16 * MAX_PATH;
char * stack_path = (char *)malloc (stack_len);
if (!stack_path)
{
Expand Down

0 comments on commit 0d95620

Please sign in to comment.