Skip to content

Commit 9ea7747

Browse files
committed
Land rapid7#9233, Fix rapid7#9232 corruption of non-latin characters in W methods
Merge branch 'land-9233' into upstream-master
2 parents c6a2ae2 + 9a81cc7 commit 9ea7747

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/rex/post/meterpreter/extensions/stdapi/railgun/library_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def asciiz_to_str(asciiz)
5353

5454
# converts ruby string to zero-terminated WCHAR string
5555
def str_to_uni_z(str)
56-
enc = str.unpack("C*").pack("v*")
56+
enc = str.encode('UTF-16LE').force_encoding('binary')
5757
enc += "\x00\x00"
5858
return enc
5959
end
6060

6161
# converts 0-terminated UTF16 to ruby string
6262
def uniz_to_str(uniz)
63-
uniz.unpack("v*").pack("C*").unpack("A*")[0]
63+
uniz.force_encoding('UTF-16LE').encode('UTF-8')
6464
end
6565

6666
# parses a number param and returns the value

0 commit comments

Comments
 (0)