Skip to content

Commit

Permalink
Client: Fix decode cfstr encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
matan1008 committed Mar 6, 2022
1 parent c043763 commit 05ac91b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/rpcclient/rpcclient/darwin/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def _decode_cfnull(self) -> None:
def _decode_cfstr(self) -> str:
ptr = self._client.symbols.CFStringGetCStringPtr(self, CFStringEncoding.kCFStringEncodingMacRoman)
if ptr:
return ptr.peek_str()
return ptr.peek_str('mac_roman')

with self._client.safe_malloc(4096) as buf:
if not self._client.symbols.CFStringGetCString(self, buf, 4096, CFStringEncoding.kCFStringEncodingMacRoman):
raise CfSerializationError('CFStringGetCString failed')
return buf.peek_str()
return buf.peek_str('mac_roman')

def _decode_cfbool(self) -> bool:
return bool(self._client.symbols.CFBooleanGetValue(self))
Expand Down
4 changes: 2 additions & 2 deletions src/rpcclient/rpcclient/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def peek(self, count):
def poke(self, buf):
return self._client.poke(self, buf)

def peek_str(self) -> str:
def peek_str(self, encoding='utf-8') -> str:
""" peek string at given address """
return self.peek(self._client.symbols.strlen(self)).decode()
return self.peek(self._client.symbols.strlen(self)).decode(encoding)

def close(self):
""" Construct compliance. """
Expand Down

0 comments on commit 05ac91b

Please sign in to comment.