From bf2b29d5e1fed0532f3f4d882e56740cddde4b96 Mon Sep 17 00:00:00 2001 From: "gordon%netscape.com" Date: Fri, 28 Jan 2000 00:34:05 +0000 Subject: [PATCH] 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. --- netwerk/dns/public/nsIDNSListener.idl | 2 +- netwerk/dns/src/nsDnsService.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/netwerk/dns/public/nsIDNSListener.idl b/netwerk/dns/public/nsIDNSListener.idl index ef2289e618c..937d888ee95 100644 --- a/netwerk/dns/public/nsIDNSListener.idl +++ b/netwerk/dns/public/nsIDNSListener.idl @@ -28,9 +28,9 @@ typedef struct nsHostEnt { PRHostEnt hostEnt; + char buffer[PR_NETDB_BUF_SIZE]; PRIntn bufLen; char * bufPtr; - char buffer[PR_NETDB_BUF_SIZE]; } nsHostEnt; %} diff --git a/netwerk/dns/src/nsDnsService.cpp b/netwerk/dns/src/nsDnsService.cpp index 6e06c74bc1a..fd87ea44a96 100644 --- a/netwerk/dns/src/nsDnsService.cpp +++ b/netwerk/dns/src/nsDnsService.cpp @@ -676,7 +676,7 @@ nsDNSService::Lookup(nsISupports* clientContext, if (PR_SUCCESS == status) { // slam the IP in and move on. PRHostEnt *ent = &(hostentry->hostEnt); - PRIntn bufLen = PR_NETDB_BUF_SIZE; + PRIntn bufLen = hostentry->bufLen = PR_NETDB_BUF_SIZE; char *buffer = hostentry->buffer; ent->h_name = (char*)BufAlloc(PL_strlen(hostName) + 1, &buffer, @@ -712,7 +712,9 @@ nsDNSService::Lookup(nsISupports* clientContext, 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; // lock dns service // search cache for existing nsDNSLookup with matching hostname @@ -736,13 +738,10 @@ nsDNSService::Lookup(nsISupports* clientContext, // if (iniateLookupNeeded) { // initiate async lookup // } - // - // create nsDNSLookup nsDNSLookup * lookup = new nsDNSLookup(clientContext, hostName, listener); if (!lookup) { - delete hostentry; return NS_ERROR_OUT_OF_MEMORY; } @@ -750,14 +749,12 @@ nsDNSService::Lookup(nsISupports* clientContext, // save on outstanding lookup queue mCompletionQueue.AppendElement(lookup); #endif - delete hostentry; (void)listener->OnStartLookup(clientContext, hostName); // initiate async lookup return lookup->InitiateDNSLookup(this); -#else - // temporary SYNC version +#else /* SYNC version of DNS Lookup */ status = PR_GetHostByName(hostName, hostentry->buffer, PR_NETDB_BUF_SIZE,