forked from puppetlabs/puppet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PUP-837) FFI Puppet::Util::Windows::SID
- FFI Win32 API functions IsValidSid, ConvertSidToStringSid, ConvertStringSidToSid and LocalFree - Unfortunately ConvertSidToStringSidW allocates a buffer and does not return it's length, therefore a new helper function has been added to FFI::Pointer that will return a string up to a maximum length. If the NULL terminator is encountered prior to the max size, no additional memory is read. This is not ideal, but slightly more secure than the previous implementation, which picked a buffer size, read all memory to the buffer, then called .strip on what remained. The helper function also imposes a maximum of 512 UTF16 characters (1024 bytes) - Presume a maximum SID string length of 184 characters when formatted per http://stackoverflow.com/a/1792930 - Add additional FFI MemoryPointer aliases for :wchar, #read_wchar - Remove any dependenc on mixins Windows::Security, Windows::Memory or Windows::MSVCRT - Updated affected callsites in security.rb to properly use or create FFI::Pointer when dealing with IsValidSid and sid_ptr_to_string. Also updated a couple of existing "old school" calls that are expecting addresses instead of FFI::Pointer objects. This is a partial refactor until work continues with making security FFI compatible.
- Loading branch information
Showing
3 changed files
with
110 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters