Skip to content

Commit

Permalink
Fixing 2x null-bytes handling for REG_MULTI_SZ values in rrp.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielg5 committed Aug 5, 2024
1 parent a6e0683 commit 170b542
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion impacket/dcerpc/v5/rrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,11 @@ def packValue(valueType, value):
retData = value.decode(sys.getfilesystemencoding()).encode('utf-16le')
elif valueType == REG_MULTI_SZ:
try:
retData = (checkNullString(value)+'\x00').encode('utf-16le')
# REG_MULTI_SZ must end with 2 null-bytes
v = checkNullString(value)
if v[-2:] != '\x00':
v = v + '\x00'
retData = v.encode('utf-16le')
except UnicodeDecodeError:
import sys
retData = value.decode(sys.getfilesystemencoding()).encode('utf-16le')
Expand Down

0 comments on commit 170b542

Please sign in to comment.