From 832ab902cf63dd42d6c75b60196dfb83d553e126 Mon Sep 17 00:00:00 2001 From: "tux.uudiin" <77389867@qq.com> Date: Tue, 8 Aug 2017 11:20:47 +0800 Subject: [PATCH] win: fix buffer size in uv__getpwuid_r() PR-URL: https://github.com/libuv/libuv/pull/1467 Reviewed-By: Colin Ihrig Reviewed-By: Bartosz Sosnowski --- src/win/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/win/util.c b/src/win/util.c index d2e7f772..a2acda11 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -1388,7 +1388,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) { if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0) return uv_translate_sys_error(GetLastError()); - bufsize = sizeof(path); + bufsize = ARRAY_SIZE(path); if (!GetUserProfileDirectoryW(token, path, &bufsize)) { r = GetLastError(); CloseHandle(token); @@ -1403,7 +1403,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) { CloseHandle(token); /* Get the username using GetUserNameW() */ - bufsize = sizeof(username); + bufsize = ARRAY_SIZE(username); if (!GetUserNameW(username, &bufsize)) { r = GetLastError();