Microsoft KB Archive/311815

= PRB: WSACleanUp Access Violation Occurs If Host Name Longer Than 54 Characters =

Article ID: 311815

Article Last Modified on 11/1/2006

-

APPLIES TO


 * Microsoft Windows NT Server 4.0 Standard Edition
 * Microsoft Windows NT Workstation 4.0 Developer Edition

-



This article was previously published under Q311815



SYMPTOMS
When you run gethostbyname, gethostbyaddr, or gethostname on a Windows NT 4.0-based computer, the API returns the correct information. However, when you call WSACleanUp, an access violation occurs and the program fails.

NOTE: This problem does not occur on Windows 2000.



RESOLUTION
To avoid this problem, do not use host names that contain more than 54 characters.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Right-click Network Neighborhood, and then click Properties. Click the Protocol tab, and then select TCP/IP. Click the Properties button. Click the DNS tab. Change the host name to a name that has at least 54 characters.  Run the following code:
 * 1) include 
 * 2) include <iostream.h>

int main(int argc,char* argv[]) {   WSADATA wsaData; char pStr[512]={0}; int ret; if(WSAStartup(0x0101,&wsaData)) { cout<<&quot;WSAStartup &quot;; cout << &quot; error: “<<WSAGetLastError<<endl; return 0; }   cout<<argv[1]<<endl; if(gethostname(pStr,512)) { cout<<&quot;gethostbyname &quot;; cout << &quot; error: “<<WSAGetLastError<<endl; WSACleanup; return 0; }   cout<<&quot;host name: &quot; <<pStr<<endl; ret=WSACleanup ; if(ret) { cout<<&quot;WSACleanup &quot;; cout << &quot; error: “<<WSAGetLastError<<endl; return 0; }   return 0; } An access violation occurs when the call is made to WSACleanUp. </li></ol>

Keywords: kbapi kbprb kbwinsock KB311815

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.