Author: hpoussin
Date: Wed Apr 12 17:41:11 2006
New Revision: 21564
URL:
http://svn.reactos.ru/svn/reactos?rev=21564&view=rev
Log:
Add missing OPTIONAL information in prototypes
Check for NULL parameters
Modified:
trunk/reactos/lib/recyclebin/ (props changed)
trunk/reactos/lib/recyclebin/openclose.c
trunk/reactos/lib/recyclebin/readme.txt
trunk/reactos/lib/recyclebin/recyclebin.c
trunk/reactos/lib/recyclebin/recyclebin.h
trunk/reactos/lib/recyclebin/recyclebin_private.h
trunk/reactos/lib/recyclebin/recyclebin_v5.c
trunk/reactos/lib/recyclebin/recyclebin_v5.h
Propchange: trunk/reactos/lib/recyclebin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Apr 12 17:41:11 2006
@@ -1,0 +1,4 @@
+*.bak
+*.gch
+GNUMakefile
+Makefile
Modified: trunk/reactos/lib/recyclebin/openclose.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/recyclebin/openclose.c?…
==============================================================================
--- trunk/reactos/lib/recyclebin/openclose.c (original)
+++ trunk/reactos/lib/recyclebin/openclose.c Wed Apr 12 17:41:11 2006
@@ -77,7 +77,7 @@
if (OwnerSid)
{
//DWORD rc;
-
+
/* Add ACL to allow only user/SYSTEM to open it */
/* FIXME: rc = SetNamedSecurityInfo(
BufferName,
@@ -114,7 +114,7 @@
}
CloseHandle(hFile);
hFile = INVALID_HANDLE_VALUE;
-
+
/* Create empty INFO2 file */
wcscpy(FileName, RECYCLE_BIN_FILE_NAME);
hFile = CreateFileW(BufferName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_HIDDEN, NULL);
@@ -140,7 +140,7 @@
if (hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
}
- return ret;
+ return ret;
}
PRECYCLE_BIN
Modified: trunk/reactos/lib/recyclebin/readme.txt
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/recyclebin/readme.txt?r…
==============================================================================
--- trunk/reactos/lib/recyclebin/readme.txt (original)
+++ trunk/reactos/lib/recyclebin/readme.txt Wed Apr 12 17:41:11 2006
@@ -6,6 +6,7 @@
- Empty a recycle bin containing directories (v5)
- Set security on recycle bin folder
- Delete files > 4Gb
+- Make the library thread-safe
3 levels
- 1: recyclebin.c: Public interface
Modified: trunk/reactos/lib/recyclebin/recyclebin.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/recyclebin/recyclebin.c…
==============================================================================
--- trunk/reactos/lib/recyclebin/recyclebin.c (original)
+++ trunk/reactos/lib/recyclebin/recyclebin.c Wed Apr 12 17:41:11 2006
@@ -20,7 +20,7 @@
IN HANDLE hDeletedFile)
{
BOOL ret = FALSE;
-
+
if (!IntCheckDeletedFileHandle(hDeletedFile))
SetLastError(ERROR_INVALID_HANDLE);
else
@@ -28,7 +28,7 @@
PDELETED_FILE_HANDLE file = (PDELETED_FILE_HANDLE)hDeletedFile;
ret = DereferenceHandle(&file->refCount);
}
-
+
return ret;
}
@@ -39,7 +39,14 @@
int len;
LPWSTR FileNameW = NULL;
BOOL ret = FALSE;
-
+
+ /* Check parameters */
+ if (FileName == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ goto cleanup;
+ }
+
len = MultiByteToWideChar(CP_ACP, 0, FileName, -1, NULL, 0);
if (len == 0)
goto cleanup;
@@ -69,6 +76,13 @@
DWORD len;
PRECYCLE_BIN bin = NULL;
BOOL ret = FALSE;
+
+ /* Check parameters */
+ if (FileName == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ goto cleanup;
+ }
/* Get full file name */
while (TRUE)
@@ -145,7 +159,7 @@
EnumerateRecycleBinA(
IN CHAR driveLetter,
IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
- IN PVOID Context)
+ IN PVOID Context OPTIONAL)
{
return EnumerateRecycleBinW((WCHAR)driveLetter, pFnCallback, Context);
}
@@ -202,10 +216,17 @@
EnumerateRecycleBinW(
IN WCHAR driveLetter,
IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
- IN PVOID Context)
+ IN PVOID Context OPTIONAL)
{
PRECYCLE_BIN bin = NULL;
BOOL ret = FALSE;
+
+ /* Check parameters */
+ if (pFnCallback == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ goto cleanup;
+ }
/* Open recycle bin */
bin = IntReferenceRecycleBin(driveLetter);
@@ -235,7 +256,7 @@
GetDeletedFileDetailsA(
IN HANDLE hDeletedFile,
IN DWORD BufferSize,
- IN OUT PDELETED_FILE_DETAILS_A FileDetails,
+ IN OUT PDELETED_FILE_DETAILS_A FileDetails OPTIONAL,
OUT LPDWORD RequiredSize OPTIONAL)
{
PDELETED_FILE_DETAILS_W FileDetailsW = NULL;
@@ -279,7 +300,7 @@
GetDeletedFileDetailsW(
IN HANDLE hDeletedFile,
IN DWORD BufferSize,
- IN OUT PDELETED_FILE_DETAILS_W FileDetails,
+ IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL,
OUT LPDWORD RequiredSize OPTIONAL)
{
BOOL ret = FALSE;
Modified: trunk/reactos/lib/recyclebin/recyclebin.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/recyclebin/recyclebin.h…
==============================================================================
--- trunk/reactos/lib/recyclebin/recyclebin.h (original)
+++ trunk/reactos/lib/recyclebin/recyclebin.h Wed Apr 12 17:41:11 2006
@@ -68,12 +68,12 @@
EnumerateRecycleBinA(
IN CHAR driveLetter,
IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
- IN PVOID Context);
+ IN PVOID Context OPTIONAL);
BOOL WINAPI
EnumerateRecycleBinW(
IN WCHAR driveLetter,
IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
- IN PVOID Context);
+ IN PVOID Context OPTIONAL);
#ifdef UNICODE
#define EnumerateRecycleBin EnumerateRecycleBinW
#else
@@ -84,13 +84,13 @@
GetDeletedFileDetailsA(
IN HANDLE hDeletedFile,
IN DWORD BufferSize,
- IN OUT PDELETED_FILE_DETAILS_A FileDetails,
+ IN OUT PDELETED_FILE_DETAILS_A FileDetails OPTIONAL,
OUT LPDWORD RequiredSize OPTIONAL);
BOOL WINAPI
GetDeletedFileDetailsW(
IN HANDLE hDeletedFile,
IN DWORD BufferSize,
- IN OUT PDELETED_FILE_DETAILS_W FileDetails,
+ IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL,
OUT LPDWORD RequiredSize OPTIONAL);
#ifdef UNICODE
#define GetDeletedFileDetails GetDeletedFileDetailsW
Modified: trunk/reactos/lib/recyclebin/recyclebin_private.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/recyclebin/recyclebin_p…
==============================================================================
--- trunk/reactos/lib/recyclebin/recyclebin_private.h (original)
+++ trunk/reactos/lib/recyclebin/recyclebin_private.h Wed Apr 12 17:41:11 2006
@@ -22,14 +22,14 @@
struct _REFCOUNT_DATA;
typedef struct _REFCOUNT_DATA *PREFCOUNT_DATA;
-typedef BOOL (*PINT_ENUMERATE_RECYCLEBIN_CALLBACK)(IN PVOID Context, IN HANDLE
hDeletedFile);
+typedef BOOL (*PINT_ENUMERATE_RECYCLEBIN_CALLBACK)(IN PVOID Context OPTIONAL, IN HANDLE
hDeletedFile);
typedef BOOL (*PDESTROY_DATA) (IN PREFCOUNT_DATA pData);
typedef BOOL (*PCLOSE_HANDLE) (IN HANDLE hHandle);
typedef BOOL (*PDELETE_FILE) (IN PRECYCLE_BIN bin, IN LPCWSTR FullPath, IN LPCWSTR
FileName);
typedef BOOL (*PEMPTY_RECYCLEBIN)(IN PRECYCLE_BIN* bin);
-typedef BOOL (*PENUMERATE_FILES) (IN PRECYCLE_BIN bin, IN
PINT_ENUMERATE_RECYCLEBIN_CALLBACK pFnCallback, IN PVOID Context);
-typedef BOOL (*PGET_DETAILS) (IN PRECYCLE_BIN bin, IN HANDLE hDeletedFile, IN DWORD
BufferSize, IN OUT PDELETED_FILE_DETAILS_W FileDetails, OUT LPDWORD RequiredSize
OPTIONAL);
+typedef BOOL (*PENUMERATE_FILES) (IN PRECYCLE_BIN bin, IN
PINT_ENUMERATE_RECYCLEBIN_CALLBACK pFnCallback, IN PVOID Context OPTIONAL);
+typedef BOOL (*PGET_DETAILS) (IN PRECYCLE_BIN bin, IN HANDLE hDeletedFile, IN DWORD
BufferSize, IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL, OUT LPDWORD RequiredSize
OPTIONAL);
typedef BOOL (*PRESTORE_FILE) (IN PRECYCLE_BIN bin, IN HANDLE hDeletedFile);
typedef struct _RECYCLEBIN_CALLBACKS
Modified: trunk/reactos/lib/recyclebin/recyclebin_v5.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/recyclebin/recyclebin_v…
==============================================================================
--- trunk/reactos/lib/recyclebin/recyclebin_v5.c (original)
+++ trunk/reactos/lib/recyclebin/recyclebin_v5.c Wed Apr 12 17:41:11 2006
@@ -189,13 +189,13 @@
EnumerateFiles5(
IN PRECYCLE_BIN bin,
IN PINT_ENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
- IN PVOID Context)
+ IN PVOID Context OPTIONAL)
{
INFO2_HEADER Header;
DELETED_FILE_RECORD DeletedFile;
DWORD bytesRead, dwEntries;
BOOL ret = FALSE;
-
+
if (SetFilePointer(bin->hInfo, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
goto cleanup;
if (!ReadFile(bin->hInfo, &Header, sizeof(INFO2_HEADER), &bytesRead, NULL))
@@ -227,7 +227,7 @@
if (SetFilePointer(bin->hInfo, sizeof(INFO2_HEADER) + Header.dwRecordSize *
dwEntries, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
goto cleanup;
}
-
+
ret = TRUE;
cleanup:
@@ -239,7 +239,7 @@
IN PRECYCLE_BIN bin,
IN HANDLE hDeletedFile,
IN DWORD BufferSize,
- IN OUT PDELETED_FILE_DETAILS_W FileDetails,
+ IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL,
OUT LPDWORD RequiredSize OPTIONAL)
{
DELETED_FILE_RECORD DeletedFile;
@@ -248,9 +248,16 @@
HANDLE hFile = INVALID_HANDLE_VALUE;
BOOL ret = FALSE;
+ /* Check parameters */
+ if (BufferSize > 0 && FileDetails == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ goto cleanup;
+ }
+
if (!IntSearchRecord(bin, hDeletedFile, &DeletedFile, NULL))
goto cleanup;
- Needed = (DWORD)FIELD_OFFSET(DELETED_FILE_DETAILS_W, FileName) +
(wcslen(DeletedFile.FileNameW) + 1) * sizeof(WCHAR);
+ Needed = FIELD_OFFSET(DELETED_FILE_DETAILS_W, FileName) + (wcslen(DeletedFile.FileNameW)
+ 1) * sizeof(WCHAR);
if (RequiredSize)
*RequiredSize = (DWORD)Needed;
if (Needed > BufferSize)
@@ -304,7 +311,7 @@
DELETED_FILE_RECORD DeletedFile, LastFile;
LPWSTR FullName = NULL;
BOOL ret = FALSE;
-
+
if (SetFilePointer(bin->hInfo, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
goto cleanup;
if (!ReadFile(bin->hInfo, &Header, sizeof(INFO2_HEADER), &bytesRead, NULL))
@@ -330,7 +337,7 @@
/* Restore file */
if (!MoveFileW(FullName, DeletedFile.FileNameW))
goto cleanup;
-
+
/* Update INFO2 */
/* 1) If not last entry, copy last entry to the current one */
if (SetFilePointer(bin->hInfo, -sizeof(DELETED_FILE_RECORD), NULL, FILE_END) ==
INVALID_SET_FILE_POINTER)
@@ -434,7 +441,7 @@
if (!IntGetFullName(bin, &DeletedFile, &FullName))
goto cleanup;
-
+
if (!IntDeleteRecursive(FullName))
goto cleanup;
ret = TRUE;
@@ -489,7 +496,7 @@
DELETED_FILE_RECORD DeletedFile;
DWORD bytesRead, dwEntries;
BOOL ret = FALSE;
-
+
if (SetFilePointer(bin->hInfo, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
goto cleanup;
if (!ReadFile(bin->hInfo, &Header, sizeof(INFO2_HEADER), &bytesRead, NULL))
Modified: trunk/reactos/lib/recyclebin/recyclebin_v5.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/recyclebin/recyclebin_v…
==============================================================================
--- trunk/reactos/lib/recyclebin/recyclebin_v5.h (original)
+++ trunk/reactos/lib/recyclebin/recyclebin_v5.h Wed Apr 12 17:41:11 2006
@@ -26,7 +26,7 @@
static BOOL
DeleteFile5(
- IN PRECYCLE_BIN Context,
+ IN PRECYCLE_BIN bin,
IN LPCWSTR FullPath,
IN LPCWSTR FileName);
@@ -38,19 +38,19 @@
EnumerateFiles5(
IN PRECYCLE_BIN bin,
IN PINT_ENUMERATE_RECYCLEBIN_CALLBACK pFnCallback,
- IN PVOID Context);
+ IN PVOID Context OPTIONAL);
static BOOL
GetDetails5(
IN PRECYCLE_BIN bin,
IN HANDLE hDeletedFile,
IN DWORD BufferSize,
- IN OUT PDELETED_FILE_DETAILS_W FileDetails,
+ IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL,
OUT LPDWORD RequiredSize OPTIONAL);
static BOOL
RestoreFile5(
- IN PRECYCLE_BIN Context,
+ IN PRECYCLE_BIN bin,
IN HANDLE hDeletedFile);
static BOOL