From 0cac35f620435f0dd18e83c7b0320f324d2f22b4 Mon Sep 17 00:00:00 2001 From: DoronZ Date: Thu, 17 Feb 2022 11:04:34 +0200 Subject: [PATCH] symbol: bugfix: call CFStringGetCString when necessary --- src/rpcclient/rpcclient/darwin/symbol.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rpcclient/rpcclient/darwin/symbol.py b/src/rpcclient/rpcclient/darwin/symbol.py index 44b51c44..5e4c17e7 100644 --- a/src/rpcclient/rpcclient/darwin/symbol.py +++ b/src/rpcclient/rpcclient/darwin/symbol.py @@ -32,7 +32,13 @@ def py(self): t = self._client._cf_types[self._client.symbols.CFGetTypeID(self)] if t == 'str': - return self._client.symbols.CFStringGetCStringPtr(self, 0).peek_str() + ptr = self._client.symbols.CFStringGetCStringPtr(self, 0) + if not ptr: + with self._client.safe_malloc(4096) as buf: + if not self._client.symbols.CFStringGetCString(self, buf, 4096, 0): + raise CfSerializationError('CFStringGetCString failed') + return buf.peek_str() + return ptr.peek_str() if t == 'bool': return bool(self._client.symbols.CFBooleanGetValue(self, 0)) if t == 'number':