No subject

Tue Aug 30 17:20:58 CDT 2005

BOOL DnsHostnameToComputerName(
  LPCTSTR Hostname,
  LPTSTR ComputerName,


[in] Pointer to a string that specifies the DNS name. If the DNS name is
not a valid, translatable name, the function fails.

[out] Pointer to a string buffer that receives the computer name. The
buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1

[in, out] On input, specifies the size of the buffer, in TCHARs. On
output, receives the number of TCHARs copied to the destination buffer,
not including the terminating null character.

If the buffer is too small, the function fails, GetLastError returns
ERROR_MORE_DATA, and nSize receives the required buffer size, not
including the terminating null character.

So at least the check should be:
if (*size < len + 1)

or you risk the computername[len+1] is invalid.

Now the second question is, which might be a convention, where does is say
that I cant set computerName size to 3*MAX_COMPUTERNAME_LENGTH and expect
it to return the computername not truncated to MAX_COMPUTERNAME_LENGTH?


More information about the wine-devel mailing list