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:
		| @@ -718,7 +718,7 @@ cygwin_gethostname (char *name, size_t len) | |||||||
| 	{ | 	{ | ||||||
| 	  DWORD local_len = len; | 	  DWORD local_len = len; | ||||||
|  |  | ||||||
| 	  if (!GetComputerNameExA (ComputerNameDnsFullyQualified, name, | 	  if (!GetComputerNameExA (ComputerNameDnsHostname, name, | ||||||
| 				   &local_len)) | 				   &local_len)) | ||||||
| 	    { | 	    { | ||||||
| 	      if (GetLastError () == ERROR_MORE_DATA) | 	      if (GetLastError () == ERROR_MORE_DATA) | ||||||
|   | |||||||
| @@ -79,3 +79,5 @@ Bug Fixes | |||||||
|   Addresses: https://cygwin.com/ml/cygwin/2018-12/msg00173.html |   Addresses: https://cygwin.com/ml/cygwin/2018-12/msg00173.html | ||||||
|  |  | ||||||
| - Fix thread names in GDB when cygthreads get reused. | - Fix thread names in GDB when cygthreads get reused. | ||||||
|  |  | ||||||
|  | - Fix return value of gethostname in a border case. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user