[WS2_32]: Fix the crash in ws2_32 reported in CORE-12852, that happens when opening e.g. Word 2010 for the first time (when it asks for registration):

- Check whether WsNcLoadProvider really succeeded in loading a provider in WsNcGetCatalogFromProviderId, and return appropriate error code.
- In WsNqLookupServiceBegin, initialize CatalogEntry to NULL prior to calling WsNcGetCatalogFromProviderId, and check for success or failure of WsNqAddProvider (and fail in accordance).

svn path=/trunk/; revision=74067
This commit is contained in:
Hermès Bélusca-Maïto 2017-03-05 00:24:08 +00:00
parent 0989caed38
commit abc2d4d228
2 changed files with 20 additions and 17 deletions

View file

@ -497,6 +497,7 @@ WsNcGetCatalogFromProviderId(IN PNSCATALOG Catalog,
IN LPGUID ProviderId, IN LPGUID ProviderId,
OUT PNSCATALOG_ENTRY *CatalogEntry) OUT PNSCATALOG_ENTRY *CatalogEntry)
{ {
INT ErrorCode = WSAEINVAL;
PLIST_ENTRY NextEntry; PLIST_ENTRY NextEntry;
PNSCATALOG_ENTRY Entry; PNSCATALOG_ENTRY Entry;
@ -514,25 +515,24 @@ WsNcGetCatalogFromProviderId(IN PNSCATALOG Catalog,
/* Check if this is the Catalog Entry ID we want */ /* Check if this is the Catalog Entry ID we want */
if (IsEqualGUID(&Entry->ProviderId, ProviderId)) if (IsEqualGUID(&Entry->ProviderId, ProviderId))
{ {
/* Check if it doesn't already have a provider */ /* If it doesn't already have a provider, load the provider */
if (!Entry->Provider) if (!Entry->Provider)
{ ErrorCode = WsNcLoadProvider(Catalog, Entry);
/* Match, load the Provider */
WsNcLoadProvider(Catalog, Entry);
}
/* Reference the entry and return it */ /* If we succeeded, reference the entry and return it */
InterlockedIncrement(&Entry->RefCount); if (Entry->Provider /* || ErrorCode == ERROR_SUCCESS */)
*CatalogEntry = Entry; {
break; InterlockedIncrement(&Entry->RefCount);
*CatalogEntry = Entry;
ErrorCode = ERROR_SUCCESS;
break;
}
} }
} }
/* Release the catalog */ /* Release the lock and return */
WsNcUnlock(); WsNcUnlock();
return ErrorCode;
/* Return */
return ERROR_SUCCESS;
} }
BOOL BOOL

View file

@ -355,7 +355,7 @@ WsNqLookupServiceBegin(IN PNSQUERY NsQuery,
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
INT ErrorCode; INT ErrorCode;
DWORD ClassInfoSize; DWORD ClassInfoSize;
PNSCATALOG_ENTRY CatalogEntry; PNSCATALOG_ENTRY CatalogEntry = NULL;
ENUM_CONTEXT EnumContext; ENUM_CONTEXT EnumContext;
BOOLEAN TryAgain; BOOLEAN TryAgain;
@ -396,10 +396,13 @@ WsNqLookupServiceBegin(IN PNSQUERY NsQuery,
ErrorCode = SOCKET_ERROR; ErrorCode = SOCKET_ERROR;
goto Exit; goto Exit;
} }
else /* We succeeded, add this provider */
else if (!WsNqAddProvider(NsQuery, CatalogEntry->Provider))
{ {
/* Add this provider */ /* Fail */
WsNqAddProvider(NsQuery, CatalogEntry->Provider); SetLastError(WSA_NOT_ENOUGH_MEMORY);
ErrorCode = SOCKET_ERROR;
goto Exit;
} }
} }
else else