Fix for bug #23709 "[top100][talkback]Crash in nsSocketTransport::OnFound on home.netscape.com cnn.com". Needed to change the order of fields in nsHostEnt so that WSAAsyncGetHostByName on Windows wouldn't overwritten the bufLen and bufPtr fields in certain cases. r=valeski.

This commit is contained in:
gordon%netscape.com 2000-01-28 00:34:05 +00:00
Родитель 8842f692fd
Коммит bf2b29d5e1
2 изменённых файлов: 6 добавлений и 9 удалений

Просмотреть файл

@ -28,9 +28,9 @@
typedef struct nsHostEnt typedef struct nsHostEnt
{ {
PRHostEnt hostEnt; PRHostEnt hostEnt;
char buffer[PR_NETDB_BUF_SIZE];
PRIntn bufLen; PRIntn bufLen;
char * bufPtr; char * bufPtr;
char buffer[PR_NETDB_BUF_SIZE];
} nsHostEnt; } nsHostEnt;
%} %}

Просмотреть файл

@ -676,7 +676,7 @@ nsDNSService::Lookup(nsISupports* clientContext,
if (PR_SUCCESS == status) { if (PR_SUCCESS == status) {
// slam the IP in and move on. // slam the IP in and move on.
PRHostEnt *ent = &(hostentry->hostEnt); PRHostEnt *ent = &(hostentry->hostEnt);
PRIntn bufLen = PR_NETDB_BUF_SIZE; PRIntn bufLen = hostentry->bufLen = PR_NETDB_BUF_SIZE;
char *buffer = hostentry->buffer; char *buffer = hostentry->buffer;
ent->h_name = (char*)BufAlloc(PL_strlen(hostName) + 1, ent->h_name = (char*)BufAlloc(PL_strlen(hostName) + 1,
&buffer, &buffer,
@ -712,7 +712,9 @@ nsDNSService::Lookup(nsISupports* clientContext,
return listener->OnStopLookup(clientContext, hostName, NS_OK); return listener->OnStopLookup(clientContext, hostName, NS_OK);
} }
} }
#if defined(XP_MAC) || defined (XP_PC) #if defined(XP_MAC) || defined (XP_PC) /* ASYNC version of DNS Lookup */
delete hostentry; // not used by async case
// initateLookupNeeded = false; // initateLookupNeeded = false;
// lock dns service // lock dns service
// search cache for existing nsDNSLookup with matching hostname // search cache for existing nsDNSLookup with matching hostname
@ -736,13 +738,10 @@ nsDNSService::Lookup(nsISupports* clientContext,
// if (iniateLookupNeeded) { // if (iniateLookupNeeded) {
// initiate async lookup // initiate async lookup
// } // }
//
// create nsDNSLookup // create nsDNSLookup
nsDNSLookup * lookup = new nsDNSLookup(clientContext, hostName, listener); nsDNSLookup * lookup = new nsDNSLookup(clientContext, hostName, listener);
if (!lookup) { if (!lookup) {
delete hostentry;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@ -750,14 +749,12 @@ nsDNSService::Lookup(nsISupports* clientContext,
// save on outstanding lookup queue // save on outstanding lookup queue
mCompletionQueue.AppendElement(lookup); mCompletionQueue.AppendElement(lookup);
#endif #endif
delete hostentry;
(void)listener->OnStartLookup(clientContext, hostName); (void)listener->OnStartLookup(clientContext, hostName);
// initiate async lookup // initiate async lookup
return lookup->InitiateDNSLookup(this); return lookup->InitiateDNSLookup(this);
#else
// temporary SYNC version
#else /* SYNC version of DNS Lookup */
status = PR_GetHostByName(hostName, status = PR_GetHostByName(hostName,
hostentry->buffer, hostentry->buffer,
PR_NETDB_BUF_SIZE, PR_NETDB_BUF_SIZE,