diff options
author | Thomas Powell <104777878+tpowell-progress@users.noreply.github.com> | 2023-04-14 12:42:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 15:42:05 -0400 |
commit | 0bfee95da8dd2d8a48a932e6bdf947c3a86ec4ff (patch) | |
tree | f305b8b7a661c114dee722a0808462fb9c144905 | |
parent | 9b252854ef7176be63d171419f2998979c52e51f (diff) | |
download | chef-0bfee95da8dd2d8a48a932e6bdf947c3a86ec4ff.tar.gz |
Avoid Invalid Memory Object error (#13677)
* Use ulong instead of pointer to prevent memory object error.
Signed-off-by: Thomas Powell <powell@progress.com>
-rw-r--r-- | lib/chef/win32/security.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb index 3894c65b21..acbc1d4c64 100644 --- a/lib/chef/win32/security.rb +++ b/lib/chef/win32/security.rb @@ -721,7 +721,13 @@ class Chef unless LogonUserW(username, domain, password, logon_type, logon_provider, token) Chef::ReservedNames::Win32::Error.raise! end - Token.new(Handle.new(token.read_pointer)) + + # originally this was .read_pointer, but that is interpreted as a non-primitive + # class (FFI::Pointer) and causes an ArgumentError (Invalid Memory Object) when + # compared to GetCurrentProcess(), which returns a HANDLE (void *). Since a + # HANDLE is not a pointer to allocated memory that Ruby C extensions can understand, + # the Invalid Memory Object error is raised. + Token.new(Handle.new(token.read_ulong)) end def self.test_and_raise_lsa_nt_status(result) |