Add fix for unintentional leaks with ntdll internals.

This commit is contained in:
Erich E. Hoover
2014-08-25 09:18:10 -06:00
parent 5f93d74102
commit ff169cd1b7
27 changed files with 449 additions and 131 deletions

View File

@@ -1,4 +1,4 @@
From b331ed482682444dfeb31358977a2645c5c194f4 Mon Sep 17 00:00:00 2001
From c7e981011339b8a665f0164fabdeb8603b247f2f Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Tue, 19 Aug 2014 20:31:00 -0600
Subject: ntdll: Unify retrieving the attributes of a file.
@@ -10,7 +10,7 @@ Subject: ntdll: Unify retrieving the attributes of a file.
3 files changed, 83 insertions(+), 40 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index a2796b2..dad2ee2 100644
index 4fb89e3..8871700 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -1380,7 +1380,7 @@ static union file_directory_info *append_entry( void *info_ptr, IO_STATUS_BLOCK
@@ -49,7 +49,7 @@ index a2796b2..dad2ee2 100644
switch (class)
{
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 92d9829..4ec2c34 100644
index 218e112..7dde57d 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -103,6 +103,55 @@ mode_t FILE_umask = 0;
@@ -108,7 +108,7 @@ index 92d9829..4ec2c34 100644
/**************************************************************************
* FILE_CreateFile (internal)
* Open a file.
@@ -1774,8 +1823,9 @@ static inline void get_file_times( const struct stat *st, LARGE_INTEGER *mtime,
@@ -1776,8 +1825,9 @@ static inline void get_file_times( const struct stat *st, LARGE_INTEGER *mtime,
#endif
}
@@ -120,7 +120,7 @@ index 92d9829..4ec2c34 100644
{
switch (class)
{
@@ -1785,10 +1835,7 @@ NTSTATUS fill_stat_info( const struct stat *st, void *ptr, FILE_INFORMATION_CLAS
@@ -1787,10 +1837,7 @@ NTSTATUS fill_stat_info( const struct stat *st, void *ptr, FILE_INFORMATION_CLAS
get_file_times( st, &info->LastWriteTime, &info->ChangeTime,
&info->LastAccessTime, &info->CreationTime );
@@ -132,7 +132,7 @@ index 92d9829..4ec2c34 100644
}
break;
case FileStandardInformation:
@@ -1824,9 +1871,9 @@ NTSTATUS fill_stat_info( const struct stat *st, void *ptr, FILE_INFORMATION_CLAS
@@ -1826,9 +1873,9 @@ NTSTATUS fill_stat_info( const struct stat *st, void *ptr, FILE_INFORMATION_CLAS
case FileAllInformation:
{
FILE_ALL_INFORMATION *info = ptr;
@@ -145,7 +145,7 @@ index 92d9829..4ec2c34 100644
}
break;
/* all directory structures start with the FileDirectoryInformation layout */
@@ -1842,30 +1889,27 @@ NTSTATUS fill_stat_info( const struct stat *st, void *ptr, FILE_INFORMATION_CLAS
@@ -1844,30 +1891,27 @@ NTSTATUS fill_stat_info( const struct stat *st, void *ptr, FILE_INFORMATION_CLAS
{
info->AllocationSize.QuadPart = 0;
info->EndOfFile.QuadPart = 0;
@@ -179,7 +179,7 @@ index 92d9829..4ec2c34 100644
}
break;
@@ -2017,6 +2061,7 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
@@ -2019,6 +2063,7 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
struct stat st;
int fd, needs_close = FALSE;
@@ -187,7 +187,7 @@ index 92d9829..4ec2c34 100644
TRACE("(%p,%p,%p,0x%08x,0x%08x)\n", hFile, io, ptr, len, class);
@@ -2041,21 +2086,21 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
@@ -2043,21 +2088,21 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
switch (class)
{
case FileBasicInformation:
@@ -213,7 +213,7 @@ index 92d9829..4ec2c34 100644
info->DeletePending = FALSE; /* FIXME */
}
}
@@ -2069,8 +2114,8 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
@@ -2071,8 +2116,8 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
}
break;
case FileInternalInformation:
@@ -224,7 +224,7 @@ index 92d9829..4ec2c34 100644
break;
case FileEaInformation:
{
@@ -2079,22 +2124,22 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
@@ -2081,22 +2126,22 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
}
break;
case FileEndOfFileInformation:
@@ -251,7 +251,7 @@ index 92d9829..4ec2c34 100644
info->StandardInformation.DeletePending = FALSE; /* FIXME */
info->EaInformation.EaSize = 0;
info->AccessInformation.AccessFlags = 0; /* FIXME */
@@ -2445,9 +2490,10 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
@@ -2447,9 +2492,10 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
if (!(status = nt_to_unix_file_name_attr( attr, &unix_name, FILE_OPEN )))
{
@@ -263,7 +263,7 @@ index 92d9829..4ec2c34 100644
status = FILE_GetNtStatus();
else if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
status = STATUS_INVALID_INFO_CLASS;
@@ -2456,8 +2502,8 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
@@ -2458,8 +2504,8 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
FILE_BASIC_INFORMATION basic;
FILE_STANDARD_INFORMATION std;
@@ -274,7 +274,7 @@ index 92d9829..4ec2c34 100644
info->CreationTime = basic.CreationTime;
info->LastAccessTime = basic.LastAccessTime;
@@ -2487,15 +2533,16 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
@@ -2489,15 +2535,16 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
if (!(status = nt_to_unix_file_name_attr( attr, &unix_name, FILE_OPEN )))
{

View File

@@ -1,4 +1,4 @@
From 38c961e5a031c4394523843b4e85a6634e34423d Mon Sep 17 00:00:00 2001
From dc4a48590aac24744291731e3c2596c762ede86b Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Tue, 19 Aug 2014 22:10:49 -0600
Subject: ntdll: Implement retrieving DOS attributes in
@@ -44,7 +44,7 @@ index 7de7a87..b77c12f 100644
AC_SUBST(dlldir,"\${libdir}/wine")
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 4ec2c34..7985dcb 100644
index 7dde57d..2b2ef15 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -103,6 +103,29 @@ mode_t FILE_umask = 0;

View File

@@ -1,4 +1,4 @@
From 89997cb9e557658b23bb4dd00273f5d2f9082fc9 Mon Sep 17 00:00:00 2001
From ddcf9ada831ef6bff1bd57c833dc368784883ece Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 16:04:34 -0600
Subject: ntdll: Implement retrieving DOS attributes in
@@ -11,7 +11,7 @@ Subject: ntdll: Implement retrieving DOS attributes in
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 7985dcb..25815a5 100644
index 2b2ef15..c551457 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -161,7 +161,8 @@ int fd_get_file_info( int fd, struct stat *st, ULONG *attr )

View File

@@ -1,4 +1,4 @@
From 05a50c64745b3af4e439702aade6aefb1d3c6040 Mon Sep 17 00:00:00 2001
From f684563e7e7306bcd773d4202f184cd3c3a7c2a8 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 00:08:52 -0600
Subject: ntdll: Implement storing DOS attributes in NtSetInformationFile.
@@ -11,7 +11,7 @@ Subject: ntdll: Implement storing DOS attributes in NtSetInformationFile.
4 files changed, 70 insertions(+), 24 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 25815a5..70f8ea3 100644
index c551457..fd21c66 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -158,6 +158,38 @@ int fd_get_file_info( int fd, struct stat *st, ULONG *attr )
@@ -53,7 +53,7 @@ index 25815a5..70f8ea3 100644
/* get the stat info and file attributes for a file (by name) */
int get_file_info( const char *path, struct stat *st, ULONG *attr )
{
@@ -2333,7 +2365,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
@@ -2335,7 +2367,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
case FileBasicInformation:
if (len >= sizeof(FILE_BASIC_INFORMATION))
{
@@ -61,7 +61,7 @@ index 25815a5..70f8ea3 100644
const FILE_BASIC_INFORMATION *info = ptr;
if ((io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
@@ -2343,25 +2374,7 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
@@ -2345,25 +2376,7 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
io->u.Status = set_file_times( fd, &info->LastWriteTime, &info->LastAccessTime );
if (io->u.Status == STATUS_SUCCESS && info->FileAttributes)

View File

@@ -1,17 +1,17 @@
From 48f69113889b2d83596fe350caf3085fa16f9bf2 Mon Sep 17 00:00:00 2001
From 61ebf9e4c09c85daa1085521facffaf394dd8db2 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 15:28:00 -0600
Subject: ntdll: Implement storing DOS attributes in NtCreateFile.
---
dlls/ntdll/file.c | 80 ++++++++++++++++++++++++++----------------
dlls/ntdll/tests/directory.c | 22 +++++-------
dlls/ntdll/file.c | 22 +++++++++++++++++++++-
dlls/ntdll/tests/directory.c | 22 ++++++++--------------
include/wine/port.h | 2 ++
libs/port/xattr.c | 31 ++++++++++++++++
4 files changed, 91 insertions(+), 44 deletions(-)
libs/port/xattr.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+), 15 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 70f8ea3..e8e5b28 100644
index fd21c66..f549552 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -217,6 +217,21 @@ int get_file_info( const char *path, struct stat *st, ULONG *attr )
@@ -36,84 +36,15 @@ index 70f8ea3..e8e5b28 100644
/**************************************************************************
* FILE_CreateFile (internal)
* Open a file.
@@ -228,6 +243,8 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
ULONG attributes, ULONG sharing, ULONG disposition,
ULONG options, PVOID ea_buffer, ULONG ea_length )
{
+ struct object_attributes objattr;
+ struct security_descriptor *sd;
ANSI_STRING unix_name;
BOOL created = FALSE;
@@ -270,40 +287,37 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
created = TRUE;
io->u.Status = STATUS_SUCCESS;
@@ -305,7 +320,6 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
}
-
- if (io->u.Status == STATUS_SUCCESS)
+ else if (io->u.Status != STATUS_SUCCESS)
{
- struct security_descriptor *sd;
- struct object_attributes objattr;
-
- objattr.rootdir = wine_server_obj_handle( attr->RootDirectory );
- objattr.name_len = 0;
- io->u.Status = NTDLL_create_struct_sd( attr->SecurityDescriptor, &sd, &objattr.sd_len );
- if (io->u.Status != STATUS_SUCCESS)
- {
- RtlFreeAnsiString( &unix_name );
- return io->u.Status;
- }
+ WARN("%s not found (%x)\n", debugstr_us(attr->ObjectName), io->u.Status );
+ return io->u.Status;
+ }
- SERVER_START_REQ( create_file )
- {
- req->access = access;
- req->attributes = attr->Attributes;
- req->sharing = sharing;
- req->create = disposition;
- req->options = options;
- req->attrs = attributes;
- wine_server_add_data( req, &objattr, sizeof(objattr) );
- if (objattr.sd_len) wine_server_add_data( req, sd, objattr.sd_len );
- wine_server_add_data( req, unix_name.Buffer, unix_name.Length );
- io->u.Status = wine_server_call( req );
- *handle = wine_server_ptr_handle( reply->handle );
- }
- SERVER_END_REQ;
- NTDLL_free_struct_sd( sd );
+ objattr.rootdir = wine_server_obj_handle( attr->RootDirectory );
+ objattr.name_len = 0;
+ io->u.Status = NTDLL_create_struct_sd( attr->SecurityDescriptor, &sd, &objattr.sd_len );
+ if (io->u.Status != STATUS_SUCCESS)
+ {
RtlFreeAnsiString( &unix_name );
+ return io->u.Status;
}
- else WARN("%s not found (%x)\n", debugstr_us(attr->ObjectName), io->u.Status );
+
+ SERVER_START_REQ( create_file )
+ {
+ req->access = access;
+ req->attributes = attr->Attributes;
+ req->sharing = sharing;
+ req->create = disposition;
+ req->options = options;
+ req->attrs = attributes;
+ wine_server_add_data( req, &objattr, sizeof(objattr) );
+ if (objattr.sd_len) wine_server_add_data( req, sd, objattr.sd_len );
+ wine_server_add_data( req, unix_name.Buffer, unix_name.Length );
+ io->u.Status = wine_server_call( req );
+ *handle = wine_server_ptr_handle( reply->handle );
+ }
+ SERVER_END_REQ;
+ NTDLL_free_struct_sd( sd );
SERVER_END_REQ;
NTDLL_free_struct_sd( sd );
- RtlFreeAnsiString( &unix_name );
if (io->u.Status == STATUS_SUCCESS)
{
@@ -325,6 +339,11 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
@@ -327,6 +341,11 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
io->Information = FILE_OVERWRITTEN;
break;
}
@@ -125,7 +56,7 @@ index 70f8ea3..e8e5b28 100644
}
else if (io->u.Status == STATUS_TOO_MANY_OPENED_FILES)
{
@@ -332,6 +351,7 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
@@ -334,6 +353,7 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
if (!once++) ERR_(winediag)( "Too many open files, ulimit -n probably needs to be increased\n" );
}

View File

@@ -1,4 +1,4 @@
From d1baa99fa107d76bd8714774ea9e5ca1d6c1c996 Mon Sep 17 00:00:00 2001
From d459f286062ea2560993829833d32fbf914ecd69 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 11:26:48 -0600
Subject: ntdll: Perform the Unix-style hidden file check within the unified
@@ -11,7 +11,7 @@ Subject: ntdll: Perform the Unix-style hidden file check within the unified
3 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index dad2ee2..0963207 100644
index 8871700..c10375d 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -1198,17 +1198,17 @@ static DWORD WINAPI init_options( RTL_RUN_ONCE *once, void *param, void **contex
@@ -48,7 +48,7 @@ index dad2ee2..0963207 100644
if (io->Information + total_len > max_length)
{
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index e8e5b28..7b72876 100644
index f549552..36ebdf4 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -210,6 +210,9 @@ int get_file_info( const char *path, struct stat *st, ULONG *attr )
@@ -61,16 +61,16 @@ index e8e5b28..7b72876 100644
/* retrieve any stored DOS attributes */
len = xattr_get( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, sizeof(hexattr)-1 );
if (len == -1) return ret;
@@ -2578,8 +2581,6 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
@@ -2580,8 +2583,6 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
info->AllocationSize = std.AllocationSize;
info->EndOfFile = std.EndOfFile;
info->FileAttributes = basic.FileAttributes;
- if (DIR_is_hidden_file( attr->ObjectName ))
- info->FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
}
RtlFreeAnsiString( &unix_name );
}
@@ -2607,11 +2608,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
else WARN("%s not found (%x)\n", debugstr_us(attr->ObjectName), status );
@@ -2609,11 +2610,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
else if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
status = STATUS_INVALID_INFO_CLASS;
else
@@ -79,9 +79,9 @@ index e8e5b28..7b72876 100644
- if (DIR_is_hidden_file( attr->ObjectName ))
- info->FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
- }
RtlFreeAnsiString( &unix_name );
}
else WARN("%s not found (%x)\n", debugstr_us(attr->ObjectName), status );
RtlFreeAnsiString( &unix_name );
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index ae59552..bacadb0 100644
--- a/dlls/ntdll/ntdll_misc.h

View File

@@ -1,4 +1,5 @@
Author: Erich E. Hoover
Subject: Implement DOS hidden/system file attributes
Revision: 1
Depends: ntdll-Fix_Free
Fixes: [9158] Support for DOS hidden/system file attributes