puppetlabs/puppet — pull request #2705 by Iristyle (2014-05-29 22:03:17+00:00)
Title: (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