From e87aaa7d59deb2f4e5bff9cb114a0c45d1ae1a5e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 16 Sep 2015 11:04:41 +0000 Subject: [PATCH] fixup! Allow overriding the home directory via the HOME variable Oh wow. Cygwin's `sys_wcstombs()` has a subtle bug in that if you use the 3-parameter version (i.e. passing an implicit (size_t)-1 as the number of input characters), it will return the number of output bytes *including* the NUL character (disagreeing with the documentation). As a consequence, the previous way to expand $HOMEDRIVE$HOMEPATH into a single buffer managed to expand *only* $HOMEDRIVE. This fixes https://github.com/git-for-windows/git/issues/414 and https://github.com/git-for-windows/git/issues/434. Signed-off-by: Johannes Schindelin --- winsup/cygwin/uinfo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 8b83998b1e..f5587d1c74 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -982,7 +982,7 @@ fetch_env(LPCWSTR key, char *buf, size_t size) if (!len || len >= max) return 0; - len = sys_wcstombs (buf, size, wbuf); + len = sys_wcstombs (buf, size, wbuf, len); return len && len < size ? len : 0; }