Skip to content

Commit 8dfa869

Browse files
authored
Merge pull request #8533 from Dorin-Pleava/PUP-10943/corrupeted_registry_main
(PUP-10943) Puppet read registry until WCHAR_NULL
2 parents 12401c3 + 9f9808d commit 8dfa869

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/puppet/ffi/windows/api_types.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def attach_function_private(*args)
2020

2121
class ::FFI::Pointer
2222
NULL_HANDLE = 0
23-
WCHAR_NULL = "\0\0".encode('UTF-16LE').freeze
23+
WCHAR_NULL = "\0\0".force_encoding('UTF-16LE').freeze
2424

2525
def self.from_string_to_wide_string(str, &block)
2626
str = Puppet::Util::Windows::String.wide_string(str)

spec/integration/util/windows/registry_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ def write_corrupt_dword(reg, valuename)
263263
type: Win32::Registry::REG_EXPAND_SZ,
264264
value: "\0\0\0reg expand string",
265265
expected_value: ""
266+
},
267+
{
268+
name: 'REG_EXPAND_SZ_2',
269+
type: Win32::Registry::REG_EXPAND_SZ,
270+
value: "1\x002\x003\x004\x00\x00\x00\x90\xD8UoY".force_encoding("UTF-16LE"),
271+
expected_value: "1234"
266272
}
267273
].each do |pair|
268274
it 'reads up to the first wide null' do

0 commit comments

Comments
 (0)