OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "util/win/registration_protocol_win.h" |
| 16 |
| 17 #include <windows.h> |
| 18 #include <sddl.h> |
| 19 #include <string.h> |
| 20 |
| 21 #include "gtest/gtest.h" |
| 22 #include "test/errors.h" |
| 23 #include "util/win/scoped_local_alloc.h" |
| 24 |
| 25 namespace crashpad { |
| 26 namespace test { |
| 27 namespace { |
| 28 |
| 29 TEST(SecurityDescriptor, MatchesAdvapi32) { |
| 30 // This security descriptor is built manually in the connection code to avoid |
| 31 // calling the advapi32 functions. Verify that it returns the same thing as |
| 32 // ConvertStringSecurityDescriptorToSecurityDescriptor() would. |
| 33 |
| 34 // Mandatory Label, no ACE flags, no ObjectType, integrity level |
| 35 // untrusted. |
| 36 const wchar_t kSddl[] = L"S:(ML;;;;;S-1-16-0)"; |
| 37 PSECURITY_DESCRIPTOR sec_desc; |
| 38 ULONG sec_desc_len; |
| 39 ASSERT_TRUE(ConvertStringSecurityDescriptorToSecurityDescriptor( |
| 40 kSddl, SDDL_REVISION_1, &sec_desc, &sec_desc_len)) |
| 41 << ErrorMessage("ConvertStringSecurityDescriptorToSecurityDescriptor"); |
| 42 ScopedLocalAlloc sec_desc_owner(sec_desc); |
| 43 |
| 44 size_t created_len; |
| 45 const void* const created = |
| 46 GetSecurityDescriptorForNamedPipeInstance(&created_len); |
| 47 ASSERT_EQ(sec_desc_len, created_len); |
| 48 EXPECT_EQ(0, memcmp(sec_desc, created, sec_desc_len)); |
| 49 } |
| 50 |
| 51 } // namespace |
| 52 } // namespace test |
| 53 } // namespace crashpad |
OLD | NEW |