From 9f25f723828d6709aad581267ccc63d2ade1ff5c Mon Sep 17 00:00:00 2001 From: Mariano Lopez Date: Mon, 28 Sep 2015 12:49:47 +0000 Subject: qemurunner: Sanitize output from qemu and qemu pid Currently the output from qemu could contain control or Unicode characters; having such characters in the log will cause an internal server error when sending the report to error reporting web. Control characters can be found in the command line used to run quemu too. This change sanitize the output from qemu and the command line used to run qemu, this way the logs doesn't contain control or Unicode characters and this will solve the issue of error reporting web and generate better logs. The only Unicode character found in the qemu output is the copyright symbol, it really doesn't interfer removing Unicode characters with debugging. [YOCTO #8225] Signed-off-by: Mariano Lopez Signed-off-by: Richard Purdie --- meta/lib/oeqa/utils/qemurunner.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'meta/lib/oeqa/utils/qemurunner.py') diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 5624977561..9c878bc707 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py @@ -13,6 +13,7 @@ import re import socket import select import errno +import string import threading from oeqa.utils.dump import HostDumper @@ -61,6 +62,9 @@ class QemuRunner: def log(self, msg): if self.logfile: + # It is needed to sanitize the data received from qemu + # because is possible to have control characters or Unicode + msg = "".join(filter(lambda x:x in string.printable, msg)) with open(self.logfile, "a") as f: f.write("%s" % msg) @@ -170,6 +174,9 @@ class QemuRunner: cmdline = '' with open('/proc/%s/cmdline' % self.qemupid) as p: cmdline = p.read() + # It is needed to sanitize the data received + # because is possible to have control characters + cmdline = "".join(filter(lambda x:x in string.printable, cmdline)) try: ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1]) if not ips or len(ips) != 3: -- cgit 1.2.3-korg