Skip to content

Commit

Permalink
Input command cant contain newlines in r2pipe.py
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jun 10, 2017
1 parent cd6e023 commit 25f3a51
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/r2pipe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
except:
has_native = False

VERSION="0.9.1"
VERSION="0.9.2"

if sys.version_info >= (3,0):
import urllib.request
Expand Down Expand Up @@ -152,6 +152,7 @@ def __init__(self, filename='', flags=[]):
self.process.stdout.read(1) # Reads initial \x00

def _cmd_process(self, cmd):
cmd = cmd.strip().replace("\n", ";")
if sys.version_info >= (3,0):
self.process.stdin.write(bytes(cmd+'\n','utf-8'))
else:
Expand All @@ -162,7 +163,7 @@ def _cmd_process(self, cmd):
foo = self.process.stdout.read(1)
if foo == b'\x00':
break
if len(foo)<1:
if len(foo) < 1:
return None
out += foo
return out.decode('utf-8')
Expand All @@ -178,6 +179,7 @@ def _cmd_tcp(self, cmd):

def _cmd_pipe(self, cmd):
out = ''
cmd = cmd.strip().replace("\n", ";")
if os.name=="nt":
fSuccess = windll.kernel32.WriteFile(self.pipe[1],cmd,len(cmd), byref(cbWritten), None)
while True:
Expand All @@ -200,6 +202,7 @@ def _cmd_pipe(self, cmd):
return out.decode('utf-8')

def _cmd_native(self, cmd):
cmd = cmd.strip().replace("\n", ";")
if not has_native:
raise Exception('No native ctypes connector available')
if not hasattr(self, 'native'):
Expand Down

0 comments on commit 25f3a51

Please sign in to comment.