You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
Add fix for unintentional leaks with ntdll internals.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
From 1725bf5deb419b54306c70b1d3b23259236b2090 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
|
||||
|
@@ -0,0 +1,24 @@
|
||||
From 8298ecb1d1eead39e9333670e79a7136ca60db50 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
|
||||
|
@@ -0,0 +1,33 @@
|
||||
From 2bde34705bcb0cf25affb6744df736611736a869 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
|
||||
|
@@ -0,0 +1,27 @@
|
||||
From 01ee64a9b96003315c521704c4e8e27b0f832b82 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
|
||||
|
@@ -0,0 +1,27 @@
|
||||
From 7ea279c6afb68865bfb6f09233e3d0fb2915fbfd 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
|
||||
|
@@ -0,0 +1,24 @@
|
||||
From fa2f0ec87a3a0b7e4d176b8a334477bbb404bc07 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
|
||||
|
@@ -0,0 +1,33 @@
|
||||
From 7d32863a7f2a412b5f42d4a60ba683d92911a251 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
|
||||
|
@@ -0,0 +1,95 @@
|
||||
From a7f6ef878680392871f8d2e00e06877fdb4182a5 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
|
||||
|
@@ -0,0 +1,24 @@
|
||||
From d52a094e2e5831a52fac98016fc71879edc8193e 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 | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
|
||||
index 09fb04b..eeba48a 100644
|
||||
--- a/dlls/kernel32/path.c
|
||||
+++ b/dlls/kernel32/path.c
|
||||
@@ -1619,6 +1619,7 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
|
||||
if (status != STATUS_SUCCESS)
|
||||
{
|
||||
SetLastError( RtlNtStatusToDosError(status) );
|
||||
+ RtlFreeAnsiString( &unix_name );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
--
|
||||
1.7.9.5
|
||||
|
@@ -0,0 +1,44 @@
|
||||
From 921d9d1c4f4a140ae8d0057079b62a0b8adb6205 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 | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
|
||||
index d396764..d580f1d 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)
|
||||
@@ -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++)
|
||||
@@ -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
|
||||
|
4
patches/ntdll-Fix_Free/definition
Normal file
4
patches/ntdll-Fix_Free/definition
Normal file
@@ -0,0 +1,4 @@
|
||||
Author: Erich E. Hoover
|
||||
Subject: Fix unintentional leaks with ntdll internals
|
||||
Revision: 1
|
||||
Fixes: Unintentional leaks with ntdll internals
|
Reference in New Issue
Block a user