1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00

Land #9233, Fix #9232 corruption of non-latin characters in W methods

Merge branch 'land-9233' into upstream-master
This commit is contained in:
bwatters-r7 2017-12-14 11:54:36 -06:00
commit 9ea7747a5c
No known key found for this signature in database
GPG Key ID: ECC0F0A52E65F268

View File

@ -53,14 +53,14 @@ module LibraryHelper
# converts ruby string to zero-terminated WCHAR string
def str_to_uni_z(str)
enc = str.unpack("C*").pack("v*")
enc = str.encode('UTF-16LE').force_encoding('binary')
enc += "\x00\x00"
return enc
end
# converts 0-terminated UTF16 to ruby string
def uniz_to_str(uniz)
uniz.unpack("v*").pack("C*").unpack("A*")[0]
uniz.force_encoding('UTF-16LE').encode('UTF-8')
end
# parses a number param and returns the value