Remove unneeded free protection patches.

This commit is contained in:
Erich E. Hoover
2014-10-02 10:19:39 -06:00
parent f2f8ea98c5
commit c4b33f044e
26 changed files with 167 additions and 500 deletions

View File

@@ -1,25 +1,17 @@
From cecc1c37484bd63da728d6dcde7aca633019bdca Mon Sep 17 00:00:00 2001
From fbb6ccb252d14593cefa5e47a5a6566406f79c40 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Thu, 28 Aug 2014 05:36:01 +0200
Subject: kernel32: Fix leaking directory handle in RemoveDirectoryW.
---
dlls/kernel32/path.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
dlls/kernel32/path.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 4a41ab8..593cc1d 100644
index 09fb04b..7e20dc3 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1602,7 +1602,6 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
SetLastError( ERROR_PATH_NOT_FOUND );
return FALSE;
}
- unix_name.Buffer = NULL;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.Attributes = OBJ_CASE_INSENSITIVE;
@@ -1613,18 +1612,21 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
@@ -1612,18 +1612,23 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
status = NtOpenFile( &handle, DELETE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
@@ -30,12 +22,12 @@ index 4a41ab8..593cc1d 100644
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
- RtlFreeAnsiString( &unix_name );
+ RtlFreeUnicodeString( &nt_name );
return FALSE;
}
- if (!(ret = (rmdir( unix_name.Buffer ) != -1))) FILE_SetDosError();
- RtlFreeAnsiString( &unix_name );
+ status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE );
+ RtlFreeUnicodeString( &nt_name );
+
@@ -44,9 +36,11 @@ index 4a41ab8..593cc1d 100644
+ else if (!(ret = (rmdir( unix_name.Buffer ) != -1)))
+ FILE_SetDosError();
+
RtlFreeAnsiString( &unix_name );
+ if (status == STATUS_SUCCESS)
+ RtlFreeAnsiString( &unix_name );
NtClose( handle );
return ret;
}
--
1.7.9.5

View File

@@ -1,24 +0,0 @@
From 87680099180ae97cdd4ab0060929e77a93ca453c Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:31:53 -0600
Subject: ntdll: Make nt_to_unix_file_name_attr return always safe to free.
---
dlls/ntdll/directory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index a2796b2..aac7522 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2941,6 +2941,7 @@ NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *
NTSTATUS status;
BOOLEAN check_case = !(attr->Attributes & OBJ_CASE_INSENSITIVE);
+ unix_name_ret->Buffer = NULL;
if (!attr->RootDirectory) /* without root dir fall back to normal lookup */
return wine_nt_to_unix_file_name( attr->ObjectName, unix_name_ret, disposition, check_case );
--
1.7.9.5

View File

@@ -1,24 +0,0 @@
From 3fdd706cddf8cf517f38488f445ca4ab30bba088 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:35:55 -0600
Subject: ntdll: Make wine_nt_to_unix_file_name return always safe to free.
---
dlls/ntdll/directory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index aac7522..01f35ab 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -3026,6 +3026,7 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
name = nameW->Buffer;
name_len = nameW->Length / sizeof(WCHAR);
+ unix_name_ret->Buffer = NULL;
if (!name_len || !IS_SEPARATOR(name[0])) return STATUS_OBJECT_PATH_SYNTAX_BAD;
--
1.7.9.5

View File

@@ -1,33 +0,0 @@
From 4394fbad092e3786360b6f7099500e26e5dbaa71 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:28:10 -0600
Subject: ntdll: Make file_id_to_unix_file_name return always safe to free.
---
dlls/ntdll/directory.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 01f35ab..9e5dbae 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2744,6 +2744,7 @@ NTSTATUS file_id_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *
ULONGLONG file_id;
struct stat st, root_st;
+ unix_name->Buffer = NULL;
if (attr->ObjectName->Length != sizeof(ULONGLONG)) return STATUS_OBJECT_PATH_SYNTAX_BAD;
if (!attr->RootDirectory) return STATUS_INVALID_PARAMETER;
memcpy( &file_id, attr->ObjectName->Buffer, sizeof(file_id) );
@@ -2802,7 +2803,7 @@ done:
else
{
TRACE( "%s not found in dir %p\n", wine_dbgstr_longlong(file_id), attr->RootDirectory );
- RtlFreeHeap( GetProcessHeap(), 0, unix_name->Buffer );
+ RtlFreeAnsiString( unix_name );
}
if (needs_close) close( root_fd );
return status;
--
1.7.9.5

View File

@@ -1,27 +0,0 @@
From e77e75d4bc2bddb96f1c1819172ac753f4508e53 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:40:09 -0600
Subject: ntdll: Fix leak on STATUS_NO_SUCH_FILE in NtQueryFullAttributesFile.
---
dlls/ntdll/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 92d9829..58edc6c 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -2469,9 +2469,9 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
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 );
return status;
}
--
1.7.9.5

View File

@@ -1,27 +0,0 @@
From 9b0b9ca377c6d93866c27b262d0b774e565e4cd3 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:40:44 -0600
Subject: ntdll: Fix leak on STATUS_NO_SUCH_FILE in NtQueryAttributesFile.
---
dlls/ntdll/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 58edc6c..03f7de8 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -2499,9 +2499,9 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
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 );
return status;
}
--
1.7.9.5

View File

@@ -1,24 +0,0 @@
From f9af5e33f532b5bcc4c9e4195efe54bbb29ed826 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:45:34 -0600
Subject: ntdll: Fix unlikely leak on STATUS_NO_SUCH_FILE in init_redirects.
---
dlls/ntdll/directory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 9e5dbae..4fb89e3 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2466,6 +2466,7 @@ static void init_redirects(void)
if (status)
{
ERR( "cannot open %s (%x)\n", debugstr_w(user_shared_data->NtSystemRoot), status );
+ RtlFreeAnsiString( &unix_name );
return;
}
if (!stat( unix_name.Buffer, &st ))
--
1.7.9.5

View File

@@ -1,33 +0,0 @@
From c8c9fa7bab2da87b6a14380265cf88bc53eea6de Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:57:06 -0600
Subject: ntdll: Fix leak on STATUS_NO_SUCH_FILE in load_builtin_dll.
---
dlls/ntdll/loader.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 79aa341..c9c2848 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1712,6 +1712,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
if (wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE ))
{
RtlFreeUnicodeString( &nt_name );
+ RtlFreeAnsiString( &unix_name );
return STATUS_DLL_NOT_FOUND;
}
prev_info = builtin_load_info;
@@ -1720,7 +1721,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
handle = wine_dlopen( unix_name.Buffer, RTLD_NOW, error, sizeof(error) );
builtin_load_info = prev_info;
RtlFreeUnicodeString( &nt_name );
- RtlFreeHeap( GetProcessHeap(), 0, unix_name.Buffer );
+ RtlFreeAnsiString( &unix_name );
if (!handle)
{
WARN( "failed to load .so lib for builtin %s: %s\n", debugstr_w(path), error );
--
1.7.9.5

View File

@@ -1,95 +0,0 @@
From 8a03ff8a255dc1a685a963acb3d6ae26478b6a6b Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 23:09:02 -0600
Subject: ntdll: Fix leak on STATUS_NO_SUCH_FILE (for certain dispositions) in
NtCreateFile.
---
dlls/ntdll/file.c | 60 +++++++++++++++++++++++++++--------------------------
1 file changed, 31 insertions(+), 29 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 03f7de8..218e112 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -114,6 +114,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;
@@ -157,39 +159,39 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
io->u.Status = STATUS_SUCCESS;
}
- if (io->u.Status == STATUS_SUCCESS)
+ 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 );
+ RtlFreeAnsiString( &unix_name );
+ 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 );
+ RtlFreeAnsiString( &unix_name );
if (io->u.Status == STATUS_SUCCESS)
{
--
1.7.9.5

View File

@@ -1,32 +0,0 @@
From a2c8ef31f29e7e6473c6c0c35a7b9681bc99f1da Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:50:19 -0600
Subject: kernel32: Fix leak on STATUS_NO_SUCH_FILE in RemoveDirectoryW.
---
dlls/kernel32/path.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 09fb04b..4a41ab8 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1602,6 +1602,7 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
SetLastError( ERROR_PATH_NOT_FOUND );
return FALSE;
}
+ unix_name.Buffer = NULL;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.Attributes = OBJ_CASE_INSENSITIVE;
@@ -1619,6 +1620,7 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
+ RtlFreeAnsiString( &unix_name );
return FALSE;
}
--
1.7.9.5

View File

@@ -1,66 +0,0 @@
From 8951f3f246da65fe632e54d0e9cbb347df231f70 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 21 Aug 2014 22:54:09 -0600
Subject: kernel32: Fix leak on STATUS_NO_SUCH_FILE in QueryDosDeviceW.
---
dlls/kernel32/volume.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index d396764..d7d3ea0 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -1354,10 +1354,8 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, TRUE );
if (status) SetLastError( RtlNtStatusToDosError(status) );
else
- {
ret = MultiByteToWideChar( CP_UNIXCP, 0, unix_name.Buffer, -1, target, bufsize );
- RtlFreeAnsiString( &unix_name );
- }
+ RtlFreeAnsiString( &unix_name );
}
done:
if (ret)
@@ -1398,9 +1396,9 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
nt_buffer[7] = '0' + i;
if (!wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, TRUE ))
{
- RtlFreeAnsiString( &unix_name );
if (p + 5 >= target + bufsize)
{
+ RtlFreeAnsiString( &unix_name );
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return 0;
}
@@ -1409,6 +1407,7 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
p[4] = 0;
p += 5;
}
+ RtlFreeAnsiString( &unix_name );
}
strcpyW( nt_buffer + 4, lptW );
for (i = 1; i <= 9; i++)
@@ -1416,9 +1415,9 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
nt_buffer[7] = '0' + i;
if (!wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, TRUE ))
{
- RtlFreeAnsiString( &unix_name );
if (p + 5 >= target + bufsize)
{
+ RtlFreeAnsiString( &unix_name );
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return 0;
}
@@ -1427,6 +1426,7 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
p[4] = 0;
p += 5;
}
+ RtlFreeAnsiString( &unix_name );
}
RtlInitUnicodeString( &nt_name, dosdevW );
--
1.7.9.5