HomePhorge

(PUP-837) FFI Puppet::Util::Windows::SID
b670abca6499Unpublished

Unpublished Commit · Learn More

Repository Importing: This repository is still importing.

Description

(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.

Details

Event Timeline

Ethan J. Brown <Iristyle@github> committed rPUb670abca6499: (PUP-837) FFI Puppet::Util::Windows::SID (authored by Ethan J. Brown <Iristyle@github>).Jun 6 2014, 1:28 AM