Answered by:
KB 4038779 problem with getnameinfo()

Question
-
Don't know whether this is a place to drop my question. Probably not. But maybe someone coudl guide me to the right place.
The following program stopped working after this patch (kb4038779) had been installed in Windows 7 Pro x64 SP1:
// gethostname.c :
//
// Testprogramm to show the failure of getnameinfo-function unter Windows (7,10, Windows Server 20xx with
// KB4038779 installed)
// CPK
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <sys/types.h>
typedef unsigned int SOCKET;
#include <Winsock2.h>
#include <ws2tcpip.h>
void usage(void);
int exit(int);
#define MAXHOSTNAMELEN 512
static char hostinfo[NI_MAXHOST];
static char hostname[MAXHOSTNAMELEN];
int main(int argc, char *argv[])
{
int result,err;
int wsreturn;
static char tmpstring[1024];
WORD wVersionRequested;
WSADATA wsaData;
SOCKADDR_IN sa;
sa.sin_family=AF_INET;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested , &wsaData );
if ( err != 0 ) {
/* Tell the user that we couldn't find a usable */
/* winsock.dll. */
printf("server: couldn't find a Winsock 2.2!\n"),exit(3);
}
if(argc !=2)
usage();
inet_pton(AF_INET,argv[1], &(sa.sin_addr));
result=getnameinfo((struct sockaddr *)&sa,
sizeof (sa),hostinfo,NI_MAXHOST,NULL,0,0);
wsreturn=WSAGetLastError();
if(wsreturn!=0)
printf("WSockError=%d\n",wsreturn);
printf("CLIENT: ip=[%s] hostinfo=[%s] result=%d wsreturn=%d\n", argv[1],hostinfo,result,wsreturn);
return 0;
}
void usage() {
printf("gethostname <IP>\nz.B. gethostname 10.172.10.35\n"),exit(1);
}Using it, gives the following result:
C:\>gethostname 172.27.1.252 ... a few (10) seconds of waiting here
CLIENT: ip=[172.27.1.252] hostinfo=[172.27.1.252] result=0 wsreturn=0
Without the patch
C:\>gethostname 172.27.1.252 ... no waiting here, immediate return
CLIENT: ip=[172.27.1.252] hostinfo=[some.host.domain] result=0 wsreturn=0
After a while the behaviour changed again to that of the situation without the patch.
--
Christoph Kukulies
- Moved by Just Karl Thursday, December 28, 2017 2:50 PM Looking for the correct forum
Wednesday, December 13, 2017 4:07 PM
Answers
-
- Proposed as answer by Dave PatrickMVP Thursday, December 28, 2017 2:58 PM
- Marked as answer by Dave PatrickMVP Saturday, December 30, 2017 2:49 AM
Thursday, December 28, 2017 2:50 PM
All replies
-
Hello,
The MSDN, TechNet and Expression Library Feedback forum is to "Help improve the Library Experience in MSDN, TechNet and Expression by providing feedback on features, bugs, look and feel or by just providing suggestions". This is not a support forum.
As it's off-topic here, I am moving the question to the Where is the forum for... forum.
Karl
Thursday, December 28, 2017 2:43 PM -
- Proposed as answer by Dave PatrickMVP Thursday, December 28, 2017 2:58 PM
- Marked as answer by Dave PatrickMVP Saturday, December 30, 2017 2:49 AM
Thursday, December 28, 2017 2:50 PM