diff --git a/src/randomenv.cpp b/src/randomenv.cpp index ddb8983c6c..9f12def2df 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include // for GetTime() #ifdef WIN32 @@ -358,10 +359,19 @@ void RandAddStaticEnv(CSHA512& hasher) hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ; // Hostname +#ifdef WIN32 + constexpr DWORD max_size = MAX_COMPUTERNAME_LENGTH + 1; + char hname[max_size]; + DWORD size = max_size; + if (GetComputerNameA(hname, &size) != 0) { + hasher.Write(UCharCast(hname), size); + } +#else char hname[256]; if (gethostname(hname, 256) == 0) { hasher.Write((const unsigned char*)hname, strnlen(hname, 256)); } +#endif #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS // Network interfaces