From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mail.openembedded.org (Postfix) with ESMTP id 0CBAA766F3 for ; Mon, 28 Sep 2015 20:02:45 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 28 Sep 2015 13:02:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,604,1437462000"; d="scan'208,217";a="799093550" Received: from mlopezva-mobl2.zpn.intel.com (HELO [10.219.16.50]) ([10.219.16.50]) by fmsmga001.fm.intel.com with ESMTP; 28 Sep 2015 13:02:27 -0700 Message-ID: <56099CD1.1090909@linux.intel.com> Date: Mon, 28 Sep 2015 15:02:25 -0500 From: Mariano Lopez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: "Burton, Ross" References: <62b26729361a797eff29928054777d7a5aebdead.1443162720.git.mariano.lopez@linux.intel.com> In-Reply-To: Cc: OE-core Subject: Re: [PATCH 1/1] qemurunner: Sanitize output from qemu and qemu pid X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 20:02:50 -0000 Content-Type: multipart/alternative; boundary="------------030900010002080102000108" --------------030900010002080102000108 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 09/28/2015 09:42 AM, Burton, Ross wrote: > On 25 September 2015 at 07:33, > wrote: > > 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 = cmdline = "".join(filter(lambda x:x in > string.printable, msg)) > with open(self.logfile, "a") as f: > f.write("%s" % msg) > > > cmdline looks like a copy/paste typo? Yes it is a copy/paste typo, I'll send a v2 > > Would it be sensible in the future to support UTF-8 for the logging? Yes, it would be possible to use UTF-8, but the main reason to use printable is not Unicode characters, it is the NULL character that sometimes appear in the qemu output and always appear in the command used to run qemu. Actually, the only non ASCII character that appears is the copyright symbol. > > Ross -- Mariano Lopez --------------030900010002080102000108 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 09/28/2015 09:42 AM, Burton, Ross wrote:
On 25 September 2015 at 07:33, <mariano.lopez@linux.intel.com> wrote:
     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 = cmdline = "".join(filter(lambda x:x in string.printable, msg))
             with open(self.logfile, "a") as f:
                 f.write("%s" % msg)

cmdline looks like a copy/paste typo?

Yes it is a copy/paste typo, I'll send a v2


Would it be sensible in the future to support UTF-8 for the logging?

Yes, it would be possible to use UTF-8, but the main reason to use printable is not Unicode characters, it is the NULL character that sometimes appear in the qemu output and always appear in the command used to run qemu. Actually, the only non ASCII character that appears is the copyright symbol.


Ross

--
Mariano Lopez
--------------030900010002080102000108--