Cygwin: gethostname: fix fetching hostname from non-winsock function

If gethostname() fails we call GetComputerNameEx with
ComputerNameDnsFullyQualified.  This is wrong, gethostname should return
the hostname only, not the FQDN.  Fix this by calling GetComputerNameEx
with ComputerNameDnsHostname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2019-01-24 14:01:59 +01:00
parent 04e3dc1128
commit c6171b9fde
2 changed files with 3 additions and 1 deletions

View File

@ -718,7 +718,7 @@ cygwin_gethostname (char *name, size_t len)
{
DWORD local_len = len;
if (!GetComputerNameExA (ComputerNameDnsFullyQualified, name,
if (!GetComputerNameExA (ComputerNameDnsHostname, name,
&local_len))
{
if (GetLastError () == ERROR_MORE_DATA)

View File

@ -79,3 +79,5 @@ Bug Fixes
Addresses: https://cygwin.com/ml/cygwin/2018-12/msg00173.html
- Fix thread names in GDB when cygthreads get reused.
- Fix return value of gethostname in a border case.