Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: da1e885becd3701d6411139a89c11ec96d121aa042798c8fb7e9b021191358fd
Ticket: da235271f1e5c582eb54a93a893a85c2cbe2b76c
[info hostname] on Windows is limited to max NetBIOS name length
User & Date: anonymous on 2020-02-21 01:41:14
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    I have a Windows host named "emake-ericm-11-2-x-202002210019-win2k12".
    Using [info hostname] on this system gives me a result of "emake-ericm-11-".
    This appears to be because in InitializeHostName() (in win/tclWinSock.c), Tcl 
    uses GetComputerNameW() to get the hostname:
    
    https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcomputernamew
    
    GetComputerNameW() is defined to return the NetBIOS name of the host, which is
    limited to MAX_COMPUTERNAME_LENGTH, which is only 15 characters, at least on 
    some versions of Windows.
    
    The documentation for [info hostname] states:
    
        Returns the name of the computer on which this invocation is being executed.  
        Note that this name is not guaranteed to be the fully qualified domain name 
        of the host.  Where  machines  have  several  different names (as is common 
        on systems with both TCP/IP (DNS) and NetBIOS-based networking installed,) 
        it is the name that is suitable for TCP/IP networking that is returned.
    
    This seems to be in contradiction to the implementation, which returns the 
    NetBIOS name, not the DNS name. Tcl should instead use GetComputerNameExW,
    which retrieves the DNS name of the host, or at least should try that first
    and only fall back to GetComputerNameW if GetComputerNameExW has failed.
    
    https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getcomputernameexw
    
  5. foundin changed to: "8.6.9"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "71ade17b2c497b778fd6637b5d0e4fcf3581ad51"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "17. Commands I-L"
  15. title changed to:
    [info hostname] on Windows is limited to max NetBIOS name length
    
  16. type changed to: "Bug"