Skip to content

Commit

Permalink
fix: crash caused by GetHostNameW on Windows 7 (fix patch regression)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Burda committed Sep 16, 2022
1 parent fa3cd17 commit 6f6b402
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion patches/node/fix_crash_caused_by_gethostnamew_on_windows_7.patch
Expand Up @@ -6,7 +6,7 @@ Subject: fix: crash caused by GetHostNameW on Windows 7
Backported from https://github.com/libuv/libuv/pull/3285.

diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c
index 33e874ac442f88b58d2b68c8ec9764f6f664552e..2d4cc0aaa02e61bf359e80eca27527efb49fd85e 100644
index 33e874ac442f88b58d2b68c8ec9764f6f664552e..eb10d0395ed55504b29efa43779e9c10965d45e1 100644
--- a/deps/uv/src/win/util.c
+++ b/deps/uv/src/win/util.c
@@ -37,6 +37,7 @@
Expand Down Expand Up @@ -166,3 +166,19 @@ index 33e874ac442f88b58d2b68c8ec9764f6f664552e..2d4cc0aaa02e61bf359e80eca27527ef
int uv_os_gethostname(char* buffer, size_t* size) {
WCHAR buf[UV_MAXHOSTNAMESIZE];
size_t len;
@@ -1674,11 +1803,11 @@ int uv_os_gethostname(char* buffer, size_t* size) {

uv__once_init(); /* Initialize winsock */

- if (pGetHostNameW == NULL)
- return UV_ENOSYS;
+ uv_sGetHostNameW gethostnamew =
+ pGetHostNameW == NULL ? uv__gethostnamew_nt60 : pGetHostNameW;

- if (pGetHostNameW(buf, UV_MAXHOSTNAMESIZE) != 0)
- return uv_translate_sys_error(WSAGetLastError());
+ if (gethostnamew(buf, UV_MAXHOSTNAMESIZE) != 0)
+ return uv_translate_sys_error(WSAGetLastError());

convert_result = uv__convert_utf16_to_utf8(buf, -1, &utf8_str);

0 comments on commit 6f6b402

Please sign in to comment.