mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-18 15:14:10 +01:00
Fixes #8732 by reading until EOF reached.
* use a lambda for cleaner iterator. * also disables buffering, since we are reading byte-by-byte in the first place and maintaining our own buffer (#data).
This commit is contained in:
parent
159beef9a9
commit
50899d608d
@ -158,15 +158,10 @@ class STDProcessBuffer(threading.Thread):
|
|||||||
self.data_lock = threading.RLock()
|
self.data_lock = threading.RLock()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while self.is_alive():
|
for byte in iter(lambda: self.std.read(1), ''):
|
||||||
byte = self.std.read(1)
|
|
||||||
self.data_lock.acquire()
|
self.data_lock.acquire()
|
||||||
self.data += byte
|
self.data += byte
|
||||||
self.data_lock.release()
|
self.data_lock.release()
|
||||||
data = self.std.read()
|
|
||||||
self.data_lock.acquire()
|
|
||||||
self.data += data
|
|
||||||
self.data_lock.release()
|
|
||||||
|
|
||||||
def is_read_ready(self):
|
def is_read_ready(self):
|
||||||
return len(self.data) != 0
|
return len(self.data) != 0
|
||||||
@ -185,6 +180,7 @@ class STDProcessBuffer(threading.Thread):
|
|||||||
|
|
||||||
class STDProcess(subprocess.Popen):
|
class STDProcess(subprocess.Popen):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
kwargs['bufsize'] = 0 # disable buffering on stdout/err
|
||||||
subprocess.Popen.__init__(self, *args, **kwargs)
|
subprocess.Popen.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user