Skip to content

Commit

Permalink
fixup! Allow overriding the home directory via the HOME variable
Browse files Browse the repository at this point in the history
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 git-for-windows/git#414 and
git-for-windows/git#434.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Sep 25, 2015
1 parent d40b472 commit e87aaa7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion winsup/cygwin/uinfo.cc
Expand Up @@ -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;
}

Expand Down

0 comments on commit e87aaa7

Please sign in to comment.