Author: gadamopoulos Date: Fri Dec 9 18:39:11 2016 New Revision: 73442
URL: http://svn.reactos.org/svn/reactos?rev=73442&view=rev Log: [SETUPAPI] - Add missing error checks in do_file_copyW. Patch by Carlo Bramini. CORE-12471
Modified: trunk/reactos/dll/win32/setupapi/queue.c
Modified: trunk/reactos/dll/win32/setupapi/queue.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/queue.c?... ============================================================================== --- trunk/reactos/dll/win32/setupapi/queue.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/queue.c [iso-8859-1] Fri Dec 9 18:39:11 2016 @@ -994,16 +994,42 @@
TRACE("copy %s to %s style 0x%x\n",debugstr_w(source),debugstr_w(target),style);
+ /* Get a temp file name */ + if (!GetTempPathW(sizeof(TempPath) / sizeof(WCHAR), TempPath)) + { + ERR("GetTempPathW error\n"); + return FALSE; + } + if (!GetTempFileNameW(TempPath, L"", 0, TempFile)) + { + ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath)); + return FALSE; + } + + /* Try to open the source file */ hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ); if (hSource < 0) + { + ERR("LZOpenFileW(1) error %d %s\n", (int)hSource, debugstr_w(source)); return FALSE; - - /* Get a temp file name */ - GetTempPathW(sizeof(TempPath) / sizeof(WCHAR), TempPath); - GetTempFileNameW(TempPath, L"", 0, TempFile); + }
/* Extract the compressed file to a temp location */ hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE); + if (hTemp < 0) + { + DWORD dwLastError = GetLastError(); + + ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile)); + + /* Close the source handle */ + LZClose(hSource); + + /* Restore error condition triggered by LZOpenFileW */ + SetLastError(dwLastError); + return FALSE; + } + LZCopy(hSource, hTemp); LZClose(hSource); LZClose(hTemp);