Author: hbelusca Date: Sun Mar 5 00:24:08 2017 New Revision: 74067
URL: http://svn.reactos.org/svn/reactos?rev=74067&view=rev Log: [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).
Modified: trunk/reactos/dll/win32/ws2_32/src/nscatalo.c trunk/reactos/dll/win32/ws2_32/src/nsquery.c
Modified: trunk/reactos/dll/win32/ws2_32/src/nscatalo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/nscata... ============================================================================== --- trunk/reactos/dll/win32/ws2_32/src/nscatalo.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/ws2_32/src/nscatalo.c [iso-8859-1] Sun Mar 5 00:24:08 2017 @@ -497,6 +497,7 @@ IN LPGUID ProviderId, OUT PNSCATALOG_ENTRY *CatalogEntry) { + INT ErrorCode = WSAEINVAL; PLIST_ENTRY NextEntry; PNSCATALOG_ENTRY Entry;
@@ -514,25 +515,24 @@ /* Check if this is the Catalog Entry ID we want */ 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) + ErrorCode = WsNcLoadProvider(Catalog, Entry); + + /* If we succeeded, reference the entry and return it */ + if (Entry->Provider /* || ErrorCode == ERROR_SUCCESS */) { - /* Match, load the Provider */ - WsNcLoadProvider(Catalog, Entry); + InterlockedIncrement(&Entry->RefCount); + *CatalogEntry = Entry; + ErrorCode = ERROR_SUCCESS; + break; } - - /* Reference the entry and return it */ - InterlockedIncrement(&Entry->RefCount); - *CatalogEntry = Entry; - break; - } - } - - /* Release the catalog */ + } + } + + /* Release the lock and return */ WsNcUnlock(); - - /* Return */ - return ERROR_SUCCESS; + return ErrorCode; }
BOOL
Modified: trunk/reactos/dll/win32/ws2_32/src/nsquery.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/nsquer... ============================================================================== --- trunk/reactos/dll/win32/ws2_32/src/nsquery.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/ws2_32/src/nsquery.c [iso-8859-1] Sun Mar 5 00:24:08 2017 @@ -355,7 +355,7 @@ PLIST_ENTRY Entry; INT ErrorCode; DWORD ClassInfoSize; - PNSCATALOG_ENTRY CatalogEntry; + PNSCATALOG_ENTRY CatalogEntry = NULL; ENUM_CONTEXT EnumContext; BOOLEAN TryAgain;
@@ -396,10 +396,13 @@ ErrorCode = SOCKET_ERROR; goto Exit; } - else - { - /* Add this provider */ - WsNqAddProvider(NsQuery, CatalogEntry->Provider); + /* We succeeded, add this provider */ + else if (!WsNqAddProvider(NsQuery, CatalogEntry->Provider)) + { + /* Fail */ + SetLastError(WSA_NOT_ENOUGH_MEMORY); + ErrorCode = SOCKET_ERROR; + goto Exit; } } else