aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGeorge McCollister <george.mccollister@gmail.com>2017-03-30 09:44:24 -0500
committerSimon Glass <sjg@chromium.org>2017-04-13 11:43:49 -0600
commit6db06f94e19d539bb7001a666e7c52672e0682ea (patch)
tree762cc5ca496a8780ed826bed854fd07fdeb887c5 /tools
parent6f8c351e98726ec9b569bf16f7efa2a4e4648727 (diff)
downloadu-boot-6db06f94e19d539bb7001a666e7c52672e0682ea.zip
u-boot-6db06f94e19d539bb7001a666e7c52672e0682ea.tar.gz
u-boot-6db06f94e19d539bb7001a666e7c52672e0682ea.tar.bz2
patman: Convert byte arrays to strings
os.read() returns a byte array in Python 3.5.2 and needs to be converted into a string. Check if the returned value is an instance of bytes and if it is decode it as a utf-8 string. If it is not a utf-8 encoded string the decoding may fail with an exception. Prior to this fix the comparisions check data == "" would fail when data was b'' and would cause an infinite memory leaking loop. joins would also fail with an exception below but due to the infinite loop it never made it that far. Signed-off-by: George McCollister <george.mccollister@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/patman/cros_subprocess.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py
index ebd4300..7c76014 100644
--- a/tools/patman/cros_subprocess.py
+++ b/tools/patman/cros_subprocess.py
@@ -190,6 +190,8 @@ class Popen(subprocess.Popen):
# We will get an error on read if the pty is closed
try:
data = os.read(self.stdout.fileno(), 1024)
+ if isinstance(data, bytes):
+ data = data.decode('utf-8')
except OSError:
pass
if data == "":
@@ -205,6 +207,8 @@ class Popen(subprocess.Popen):
# We will get an error on read if the pty is closed
try:
data = os.read(self.stderr.fileno(), 1024)
+ if isinstance(data, bytes):
+ data = data.decode('utf-8')
except OSError:
pass
if data == "":