From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=32817 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pq2jW-0001Iq-1n for qemu-devel@nongnu.org; Thu, 17 Feb 2011 07:13:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pq2jR-0001Xb-KT for qemu-devel@nongnu.org; Thu, 17 Feb 2011 07:13:17 -0500 Received: from mail-vw0-f45.google.com ([209.85.212.45]:38627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pq2jR-0001XQ-Ej for qemu-devel@nongnu.org; Thu, 17 Feb 2011 07:13:13 -0500 Received: by vws12 with SMTP id 12so1108981vws.4 for ; Thu, 17 Feb 2011 04:13:13 -0800 (PST) Message-ID: <4D5D10C1.9010209@codemonkey.ws> Date: Thu, 17 Feb 2011 06:12:49 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] KVM call minutes for Feb 15 References: <20110215162629.GN21720@x200.localdomain> <4D5B0889.4030303@codemonkey.ws> <4D5BA5E9.90307@redhat.com> <4D5BD259.3080804@codemonkey.ws> <4D5CE9AB.2030503@redhat.com> In-Reply-To: <4D5CE9AB.2030503@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Chris Wright , qemu-devel@nongnu.org, kvm@vger.kernel.org On 02/17/2011 03:26 AM, Avi Kivity wrote: > On 02/16/2011 03:34 PM, Anthony Liguori wrote: >> On 02/16/2011 04:24 AM, Avi Kivity wrote: >>> On 02/16/2011 01:13 AM, Anthony Liguori wrote: >>>> On 02/15/2011 10:26 AM, Chris Wright wrote: >>>>> QAPI and QMP >>>>> - Anthony adding a new wiki page to describe all of this >>>> >>>> http://wiki.qemu.org/Features/QAPI >>>> >>> >>> [ 'change', {'device': 'str', 'target': 'str'}, {'arg': 'str'}, >>> 'none' ] >>> -> >>> void qmp_change(const char *device, const char *target, bool >>> has_arg, const char *arg, Error **errp); >>> >>> AFAICT a json-string allows embedded NULs ('\0000'). There >>> translate to UTF-8 as '\0', terminating your char *s. Either we use >>> some length/pointer structure, or the parser has to look for them >>> and kill them, and we have to specify them as verboten. >> >> I feel like it would be safer for us to not accept strings with >> embedded NULs. There's no way we're going to consistently handle >> this correctly in QEMU since we expect NUL terminated strings. They >> won't work for any of the standard C functions either. > > I agree. Technically we're making a backwards incompatible change to > the protocol specification, but I don't think there's any risk that > somebody is sending in strings with NULs. > > (btw what happens in a non-UTF-8 locale? I guess we should just reject > unencodable strings). While QEMU is mostly ASCII internally, for the purposes of the JSON parser, we always encode and decode UTF-8. We reject invalid UTF-8 sequences. But since JSON is string-encoded unicode, we can always decode a JSON string to valid UTF-8 as long as the string is well formed. Regards, Anthony Liguori