From 85b4e675141ea185f27b906ebe9b7c5c56c65469 Mon Sep 17 00:00:00 2001 From: patr0nus Date: Mon, 1 Nov 2021 17:37:01 +0800 Subject: [PATCH] Patch uv for win7 compatiblity Reverts https://github.com/libuv/libuv/commit/95f88f47f28b4686a6959377c8d2c31daa40bd64 --- libnode/patch/node.patch | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/libnode/patch/node.patch b/libnode/patch/node.patch index b6de7c5..ed6a1cd 100644 --- a/libnode/patch/node.patch +++ b/libnode/patch/node.patch @@ -19,3 +19,44 @@ 'src/js_native_api.h', 'src/js_native_api_types.h', 'src/node_api_types.h', +--- a/deps/uv/src/win/util.c ++++ b/deps/uv/src/win/util.c +@@ -1664,33 +1664,26 @@ int uv_os_unsetenv(const char* name) { + + + int uv_os_gethostname(char* buffer, size_t* size) { +- WCHAR buf[UV_MAXHOSTNAMESIZE]; ++ char buf[UV_MAXHOSTNAMESIZE]; + size_t len; +- char* utf8_str; +- int convert_result; + + if (buffer == NULL || size == NULL || *size == 0) + return UV_EINVAL; + + uv__once_init(); /* Initialize winsock */ + +- if (GetHostNameW(buf, UV_MAXHOSTNAMESIZE) != 0) ++ if (gethostname(buf, sizeof(buf)) != 0) + return uv_translate_sys_error(WSAGetLastError()); + +- convert_result = uv__convert_utf16_to_utf8(buf, -1, &utf8_str); ++ buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */ ++ len = strlen(buf); + +- if (convert_result != 0) +- return convert_result; +- +- len = strlen(utf8_str); + if (len >= *size) { + *size = len + 1; +- uv__free(utf8_str); + return UV_ENOBUFS; + } + +- memcpy(buffer, utf8_str, len + 1); +- uv__free(utf8_str); ++ memcpy(buffer, buf, len + 1); + *size = len; + return 0; + }