Rebase against a455ff61b40ff73b48d0ccc9c1f14679bb65ab8d.

This commit is contained in:
Zebediah Figura
2020-07-20 19:55:28 -05:00
parent 26d3815d8c
commit 4373a1011e
16 changed files with 278 additions and 368 deletions

View File

@@ -1,19 +1,19 @@
From 77f149959058b5e45a2fd462b5077ae417bc5857 Mon Sep 17 00:00:00 2001
From 81bd9eaa0466b7adc763d4302ca70141f8aa3947 Mon Sep 17 00:00:00 2001
From: Qian Hong <qhong@codeweavers.com>
Date: Tue, 16 Feb 2016 04:53:12 +0800
Subject: ntdll: Improve invalid paramater handling in NtAccessCheck.
Subject: [PATCH] ntdll: Improve invalid paramater handling in NtAccessCheck.
Signed-off-by: Qian Hong <qhong@codeweavers.com>
---
dlls/advapi32/tests/security.c | 8 --------
dlls/ntdll/sec.c | 11 ++++++++++-
2 files changed, 10 insertions(+), 9 deletions(-)
dlls/advapi32/tests/security.c | 8 --------
dlls/ntdll/unix/security.c | 8 +++++++-
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 8b86d45..698a9aa 100644
index 825f8451904..ca6e735c1c6 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -1429,10 +1429,8 @@ static void test_AccessCheck(void)
@@ -1466,10 +1466,8 @@ static void test_AccessCheck(void)
ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping,
0, &PrivSetLen, &Access, &AccessStatus);
err = GetLastError();
@@ -24,7 +24,7 @@ index 8b86d45..698a9aa 100644
ok(PrivSetLen == sizeof(PRIVILEGE_SET), "PrivSetLen returns %d\n", PrivSetLen);
ok(Access == 0x1abe11ed && AccessStatus == 0x1abe11ed,
"Access and/or AccessStatus were changed!\n");
@@ -1483,12 +1481,9 @@ todo_wine
@@ -1520,12 +1518,9 @@ todo_wine
ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping,
PrivSet, &PrivSetLen, &Access, &AccessStatus);
err = GetLastError();
@@ -37,7 +37,7 @@ index 8b86d45..698a9aa 100644
ok(Access == 0x1abe11ed && AccessStatus == 0x1abe11ed,
"Access and/or AccessStatus were changed!\n");
@@ -1600,12 +1595,9 @@ todo_wine
@@ -1637,12 +1632,9 @@ todo_wine
ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping,
PrivSet, &PrivSetLen, &Access, &AccessStatus);
err = GetLastError();
@@ -50,28 +50,25 @@ index 8b86d45..698a9aa 100644
ok(Access == 0x1abe11ed && AccessStatus == 0x1abe11ed,
"Access and/or AccessStatus were changed!\n");
diff --git a/dlls/ntdll/sec.c b/dlls/ntdll/sec.c
index 125c86e..c32ae0c 100644
--- a/dlls/ntdll/sec.c
+++ b/dlls/ntdll/sec.c
@@ -1586,7 +1586,16 @@ NtAccessCheck(
SecurityDescriptor, ClientToken, DesiredAccess, GenericMapping,
PrivilegeSet, ReturnLength, GrantedAccess, AccessStatus);
diff --git a/dlls/ntdll/unix/security.c b/dlls/ntdll/unix/security.c
index daecc5e0591..c1237859784 100644
--- a/dlls/ntdll/unix/security.c
+++ b/dlls/ntdll/unix/security.c
@@ -650,7 +650,13 @@ NTSTATUS WINAPI NtAccessCheck( PSECURITY_DESCRIPTOR descr, HANDLE token, ACCESS_
TRACE( "(%p, %p, %08x, %p, %p, %p, %p, %p)\n",
descr, token, access, mapping, privs, retlen, access_granted, access_status );
- if (!PrivilegeSet || !ReturnLength)
+ if (!ReturnLength)
+ return STATUS_ACCESS_VIOLATION;
+
+ if (*ReturnLength == 0)
- if (!privs || !retlen) return STATUS_ACCESS_VIOLATION;
+ if (!retlen) return STATUS_ACCESS_VIOLATION;
+ if (!*retlen)
+ {
+ *ReturnLength = sizeof(PRIVILEGE_SET);
+ *retlen = sizeof(PRIVILEGE_SET);
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ if (!PrivilegeSet)
return STATUS_ACCESS_VIOLATION;
+ if (!privs) return STATUS_ACCESS_VIOLATION;
SERVER_START_REQ( access_check )
/* reuse the object attribute SD marshalling */
InitializeObjectAttributes( &attr, NULL, 0, 0, descr );
--
2.7.1
2.27.0