From: Johannes Schindelin Date: Thu, 4 Jul 2019 22:36:57 +0000 (-0700) Subject: mingw: fix possible buffer overrun when calling `GetUserNameW()` X-Git-Tag: v2.23.0-rc0~43^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=697bdd22b887a0778489814e44dcec850aa82ad0;p=thirdparty%2Fgit.git mingw: fix possible buffer overrun when calling `GetUserNameW()` In 39a98e9b68b8 (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 Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff --git a/compat/mingw.c b/compat/mingw.c index b8a62bf914..a0eb695653 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1952,7 +1952,7 @@ struct passwd *getpwuid(int uid) if (initialized) return p; - len = sizeof(buf); + len = ARRAY_SIZE(buf); if (!GetUserNameW(buf, &len)) { initialized = 1; return NULL;