diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2015-09-28 12:49:47 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-09-29 15:15:48 +0100 |
commit | 9f25f723828d6709aad581267ccc63d2ade1ff5c (patch) | |
tree | 42ecf164f8b67961b962c1d2b8988a1b6b90f620 /meta/lib/oeqa/utils | |
parent | 3bf5204315fedc586fdf641583cfdb2c1a78c5c0 (diff) | |
download | openembedded-core-9f25f723828d6709aad581267ccc63d2ade1ff5c.tar.gz openembedded-core-9f25f723828d6709aad581267ccc63d2ade1ff5c.tar.bz2 openembedded-core-9f25f723828d6709aad581267ccc63d2ade1ff5c.zip |
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 <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 7 |
1 files changed, 7 insertions, 0 deletions
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: |