From 60ae071827706ab926e2f557280973313912811d Mon Sep 17 00:00:00 2001 From: hater <7element@mail.bg> Date: Wed, 4 Nov 2015 11:33:59 +0200 Subject: [PATCH] Fix getxyDataEnt to fill flags depending on call and fix gethostname to expect missing blob. Disable debug messages --- reactos/dll/win32/ws2_32_new/src/getxbyxx.c | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/ws2_32_new/src/getxbyxx.c b/reactos/dll/win32/ws2_32_new/src/getxbyxx.c index bd2f1bb..e8c861b 100644 --- a/reactos/dll/win32/ws2_32_new/src/getxbyxx.c +++ b/reactos/dll/win32/ws2_32_new/src/getxbyxx.c @@ -10,7 +10,7 @@ #include -//#define NDEBUG +#define NDEBUG #include /* DATA **********************************************************************/ @@ -108,9 +108,11 @@ getxyDataEnt(IN OUT PCHAR *Results, { PWSAQUERYSETA WsaQuery = (PWSAQUERYSETA)*Results; INT ErrorCode; + DWORD NewLength = Length; HANDLE RnRHandle; LPBLOB Blob = NULL; - PVOID NewResults; + PVOID NewResults = NULL; + DWORD dwControlFlags = LUP_RETURN_NAME; /* Assume empty return name */ if (NewName) *NewName = NULL; @@ -121,12 +123,15 @@ getxyDataEnt(IN OUT PCHAR *Results, WsaQuery->lpszServiceInstanceName = Name; WsaQuery->lpServiceClassId = (LPGUID)Type; WsaQuery->dwNameSpace = NS_ALL; - WsaQuery->dwNumberOfProtocols = 2; - WsaQuery->lpafpProtocols = &afp[0]; + WsaQuery->dwNumberOfProtocols = sizeof(afp)/sizeof(afp[0]); + WsaQuery->lpafpProtocols = afp; + + if(!IsEqualGUID(Type, &HostnameGuid)) + dwControlFlags |= LUP_RETURN_BLOB; /* Send the Query Request to find a Service */ ErrorCode = WSALookupServiceBeginA(WsaQuery, - LUP_RETURN_BLOB | LUP_RETURN_NAME, + dwControlFlags, &RnRHandle); if(ErrorCode == ERROR_SUCCESS) @@ -136,7 +141,7 @@ getxyDataEnt(IN OUT PCHAR *Results, /* Service was found, send the real query */ ErrorCode = WSALookupServiceNextA(RnRHandle, 0, - &Length, + &NewLength, WsaQuery); /* Return the information requested */ @@ -152,7 +157,7 @@ getxyDataEnt(IN OUT PCHAR *Results, else { /* Check if this was a Hostname lookup */ - if (Type == &HostnameGuid) + if (IsEqualGUID(Type, &HostnameGuid)) { /* Return the name anyways */ if(NewName) *NewName = WsaQuery->lpszServiceInstanceName; @@ -389,19 +394,21 @@ gethostbyaddr(IN const char FAR * addr, */ INT WSAAPI -gethostname(OUT char FAR * name, - IN int namelen) +gethostname(OUT CHAR FAR * name, + IN INT namelen) { - PCHAR Name; + PCHAR Name = NULL; CHAR ResultsBuffer[RNR_BUFFER_SIZE]; PCHAR Results = ResultsBuffer; DPRINT("gethostname: %p\n", name); /* Get the Hostname in a String */ - if(getxyDataEnt(&Results, RNR_BUFFER_SIZE, NULL, &HostnameGuid, &Name)) + /* getxyDataEnt does not return blob for HostnameGuid */ + getxyDataEnt(&Results, RNR_BUFFER_SIZE, NULL, &HostnameGuid, &Name); + if(Name) { /* Copy it */ - strcpy((LPSTR)name, Name); + strncpy((LPSTR)name, Name, namelen-1); } /* Check if we received a newly allocated buffer; free it. */ -- 1.9.5.msysgit.0