Skip to content

Commit

Permalink
git-wrapper: fix interpolation with short values
Browse files Browse the repository at this point in the history
To be precise: when the value of the environment variable is shorter than
its name, we have to move the remaining bytes *after* expanding the
environment variable: we would look for the wrong name otherwise.

When the value is longer than the name, we still need to move the bytes
out of the way first, to avoid overwriting them with the interpolated
text.

This fixes #509

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Aug 13, 2016
1 parent 6346be8 commit f52b88b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compat/win32/git-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
if (delta > 0)
memmove(atat2 + delta, atat2, move_len);
len += delta;
save = atat[env_len - 1];
save = atat[env_len - 1 + (delta < 0 ? -delta : 0)];
GetEnvironmentVariable(atat + 2, atat, env_len);
if (delta < 0)
memmove(atat2 + delta, atat2, move_len);
atat[env_len - 1] = save;
}

Expand Down

0 comments on commit f52b88b

Please sign in to comment.