diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index e0c26bd36..883bb6de5 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -1170,7 +1171,10 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) WINPR_ASSERT(rdpdr); if (!rdpdr->computerName[0]) - gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1); + { + DWORD size = sizeof(rdpdr->computerName) - 1; + GetComputerNameA(rdpdr->computerName, &size); + } computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2; WINPR_ASSERT(computerNameLenW >= 0); diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 0d3d8a4a0..1a08e75c2 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -431,7 +431,8 @@ rdpSettings* freerdp_settings_new(DWORD flags) { char ClientHostname[33] = { 0 }; - gethostname(ClientHostname, 31); + DWORD size = sizeof(ClientHostname) - 2; + GetComputerNameA(ClientHostname, &size); if (!freerdp_settings_set_string(settings, FreeRDP_ClientHostname, ClientHostname)) goto out_fail; }