From 9235a89d1af0fa0c74006b020068edb823f000c4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 2 Mar 2015 14:09:29 +0300 Subject: [PATCH] arg_heuristic(): be better prepared to handle path lists 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: https://github.com/git-for-windows/git/issues/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 --- winsup/cygwin/path.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index e71db51b2d..773e64659d 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3510,7 +3510,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) {