wine/dlls/ntdll tests/rtl.c sec.c
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Nov 15 06:03:46 CST 2005
ChangeSet ID: 21274
CVSROOT: /opt/cvs-commit
Module name: wine
Changes by: julliard at winehq.org 2005/11/15 06:03:46
Modified files:
dlls/ntdll/tests: rtl.c
dlls/ntdll : sec.c
Log message:
Dmitry Timoshkov <dmitry at codeweavers.com>
Add a test for RtlAllocateAndInitializeSid, make it pass under Wine.
Patch: http://cvs.winehq.org/patch.py?id=21274
Old revision New revision Changes Path
1.17 1.18 +25 -0 wine/dlls/ntdll/tests/rtl.c
1.67 1.68 +28 -28 wine/dlls/ntdll/sec.c
Index: wine/dlls/ntdll/tests/rtl.c
diff -u -p wine/dlls/ntdll/tests/rtl.c:1.17 wine/dlls/ntdll/tests/rtl.c:1.18
--- wine/dlls/ntdll/tests/rtl.c:1.17 15 Nov 2005 12: 3:46 -0000
+++ wine/dlls/ntdll/tests/rtl.c 15 Nov 2005 12: 3:46 -0000
@@ -64,6 +64,8 @@ static BOOLEAN (WINAPI * pRtlIsValidIn
static NTSTATUS (WINAPI * pRtlDestroyHandleTable)(RTL_HANDLE_TABLE *);
static RTL_HANDLE * (WINAPI * pRtlAllocateHandle)(RTL_HANDLE_TABLE *, ULONG *);
static BOOLEAN (WINAPI * pRtlFreeHandle)(RTL_HANDLE_TABLE *, RTL_HANDLE *);
+static NTSTATUS (WINAPI *pRtlAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY,BYTE,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,PSID*);
+static NTSTATUS (WINAPI *pRtlFreeSid)(PSID);
#define LEN 16
static const char* src_src = "This is a test!"; /* 16 bytes long, incl NUL */
static ULONG src_aligned_block[4];
@@ -93,6 +95,8 @@ static void InitFunctionPtrs(void)
pRtlDestroyHandleTable = (void *)GetProcAddress(hntdll, "RtlDestroyHandleTable");
pRtlAllocateHandle = (void *)GetProcAddress(hntdll, "RtlAllocateHandle");
pRtlFreeHandle = (void *)GetProcAddress(hntdll, "RtlFreeHandle");
+ pRtlAllocateAndInitializeSid = (void *)GetProcAddress(hntdll, "RtlAllocateAndInitializeSid");
+ pRtlFreeSid = (void *)GetProcAddress(hntdll, "RtlFreeSid");
}
strcpy((char*)src_aligned_block, src_src);
ok(strlen(src) == 15, "Source must be 16 bytes long!\n");
@@ -878,6 +882,25 @@ static void test_HandleTables(void)
ok(status == STATUS_SUCCESS, "RtlDestroyHandleTable failed with error 0x%08lx\n", status);
}
+static void test_RtlAllocateAndInitializeSid(void)
+{
+ NTSTATUS ret;
+ SID_IDENTIFIER_AUTHORITY sia = {{ 1, 2, 3, 4, 5, 6 }};
+ PSID psid;
+
+ ret = pRtlAllocateAndInitializeSid(&sia, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid);
+ ok(!ret, "RtlAllocateAndInitializeSid error %08lx\n", ret);
+ ret = pRtlFreeSid(psid);
+ ok(!ret, "RtlFreeSid error %08lx\n", ret);
+
+ /* these tests crash on XP
+ ret = pRtlAllocateAndInitializeSid(NULL, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid);
+ ret = pRtlAllocateAndInitializeSid(&sia, 0, 1, 2, 3, 4, 5, 6, 7, 8, NULL);*/
+
+ ret = pRtlAllocateAndInitializeSid(&sia, 9, 1, 2, 3, 4, 5, 6, 7, 8, &psid);
+ ok(ret == STATUS_INVALID_SID, "wrong error %08lx\n", ret);
+}
+
START_TEST(rtl)
{
InitFunctionPtrs();
@@ -908,4 +931,6 @@ START_TEST(rtl)
test_RtlComputeCrc32();
if (pRtlInitializeHandleTable)
test_HandleTables();
+ if (pRtlAllocateAndInitializeSid)
+ test_RtlAllocateAndInitializeSid();
}
Index: wine/dlls/ntdll/sec.c
diff -u -p wine/dlls/ntdll/sec.c:1.67 wine/dlls/ntdll/sec.c:1.68
--- wine/dlls/ntdll/sec.c:1.67 15 Nov 2005 12: 3:46 -0000
+++ wine/dlls/ntdll/sec.c 15 Nov 2005 12: 3:46 -0000
@@ -135,41 +135,41 @@ NTSTATUS WINAPI RtlAllocateAndInitialize
DWORD nSubAuthority6, DWORD nSubAuthority7,
PSID *pSid )
{
+ SID *tmp_sid;
- TRACE("(%p, 0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,%p)\n",
+ TRACE("(%p, 0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,%p)\n",
pIdentifierAuthority,nSubAuthorityCount,
nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, pSid);
- if (!(*pSid = RtlAllocateHeap( GetProcessHeap(), 0,
- RtlLengthRequiredSid(nSubAuthorityCount))))
- return STATUS_NO_MEMORY;
+ if (nSubAuthorityCount > 8) return STATUS_INVALID_SID;
- ((SID*)*pSid)->Revision = SID_REVISION;
-
- if (pIdentifierAuthority)
- memcpy(&((SID*)*pSid)->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
- *RtlSubAuthorityCountSid(*pSid) = nSubAuthorityCount;
-
- if (nSubAuthorityCount > 0)
- *RtlSubAuthoritySid(*pSid, 0) = nSubAuthority0;
- if (nSubAuthorityCount > 1)
- *RtlSubAuthoritySid(*pSid, 1) = nSubAuthority1;
- if (nSubAuthorityCount > 2)
- *RtlSubAuthoritySid(*pSid, 2) = nSubAuthority2;
- if (nSubAuthorityCount > 3)
- *RtlSubAuthoritySid(*pSid, 3) = nSubAuthority3;
- if (nSubAuthorityCount > 4)
- *RtlSubAuthoritySid(*pSid, 4) = nSubAuthority4;
- if (nSubAuthorityCount > 5)
- *RtlSubAuthoritySid(*pSid, 5) = nSubAuthority5;
- if (nSubAuthorityCount > 6)
- *RtlSubAuthoritySid(*pSid, 6) = nSubAuthority6;
- if (nSubAuthorityCount > 7)
- *RtlSubAuthoritySid(*pSid, 7) = nSubAuthority7;
-
- return STATUS_SUCCESS;
+ if (!(tmp_sid= RtlAllocateHeap( GetProcessHeap(), 0,
+ RtlLengthRequiredSid(nSubAuthorityCount))))
+ return STATUS_NO_MEMORY;
+
+ tmp_sid->Revision = SID_REVISION;
+
+ if (pIdentifierAuthority)
+ memcpy(&tmp_sid->IdentifierAuthority, pIdentifierAuthority, sizeof(SID_IDENTIFIER_AUTHORITY));
+ tmp_sid->SubAuthorityCount = nSubAuthorityCount;
+
+ switch( nSubAuthorityCount )
+ {
+ case 8: tmp_sid->SubAuthority[7]= nSubAuthority7;
+ case 7: tmp_sid->SubAuthority[6]= nSubAuthority6;
+ case 6: tmp_sid->SubAuthority[5]= nSubAuthority5;
+ case 5: tmp_sid->SubAuthority[4]= nSubAuthority4;
+ case 4: tmp_sid->SubAuthority[3]= nSubAuthority3;
+ case 3: tmp_sid->SubAuthority[2]= nSubAuthority2;
+ case 2: tmp_sid->SubAuthority[1]= nSubAuthority1;
+ case 1: tmp_sid->SubAuthority[0]= nSubAuthority0;
+ break;
+ }
+ *pSid = tmp_sid;
+ return STATUS_SUCCESS;
}
+
/******************************************************************************
* RtlEqualSid [NTDLL.@]
*
More information about the wine-cvs
mailing list