Skip to content

Commit 697bdd2

Browse files
dschogitster
authored andcommitted
mingw: fix possible buffer overrun when calling GetUserNameW()
In 39a98e9 (mingw: get pw_name in UTF-8 format, 2019-06-27), this developer missed the fact that the `GetUserNameW()` function takes the number of characters as `len` parameter, not the number of bytes. Reported-by: Beat Bolli <dev+git@drbeat.li> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9423885 commit 697bdd2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compat/mingw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,7 @@ struct passwd *getpwuid(int uid)
19521952
if (initialized)
19531953
return p;
19541954

1955-
len = sizeof(buf);
1955+
len = ARRAY_SIZE(buf);
19561956
if (!GetUserNameW(buf, &len)) {
19571957
initialized = 1;
19581958
return NULL;

0 commit comments

Comments
 (0)