From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzpY5-0000Nx-P1 for qemu-devel@nongnu.org; Fri, 20 Nov 2015 12:32:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzpY2-00017a-Ee for qemu-devel@nongnu.org; Fri, 20 Nov 2015 12:32:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzpY2-00017S-9h for qemu-devel@nongnu.org; Fri, 20 Nov 2015 12:32:34 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E10E4B8923 for ; Fri, 20 Nov 2015 17:32:33 +0000 (UTC) References: <1447946948-12489-1-git-send-email-armbru@redhat.com> <1447946948-12489-5-git-send-email-armbru@redhat.com> <564E46AD.4030901@redhat.com> <87egflqjty.fsf@blackfin.pond.sub.org> <564EDEE3.80000@redhat.com> From: Eric Blake Message-ID: <564F592D.4080305@redhat.com> Date: Fri, 20 Nov 2015 10:32:29 -0700 MIME-Version: 1.0 In-Reply-To: <564EDEE3.80000@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="srIR8fR7svFnNJQ7U4W2JgW8WqvqBUpGR" Subject: Re: [Qemu-devel] [PATCH v2 4/4] json-streamer: Limit number of tokens in addition to total size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Markus Armbruster Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --srIR8fR7svFnNJQ7U4W2JgW8WqvqBUpGR Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/20/2015 01:50 AM, Paolo Bonzini wrote: >=20 >=20 > On 20/11/2015 07:13, Markus Armbruster wrote: >>>> @@ -64,6 +65,7 @@ static void json_message_process_token(JSONLexer *= lexer, QString *token, JSONTok >>>> parser->bracket_count =3D=3D 0)) { >>>> goto out_emit; >>>> } else if (parser->token_size > MAX_TOKEN_SIZE || >>>> + qlist_size(parser->tokens) > MAX_TOKEN_COUNT || >>> >>> This is O(n^2). I'd rather skip this patch, fix the memory hog and >>> possibly decrease MAX_TOKEN_SIZE a bit. >> >> I can't see the square right now. >=20 > It's hidden in qlist_size: >=20 > static void qlist_size_iter(QObject *obj, void *opaque) > { > size_t *count =3D opaque; > (*count)++; > } Yuck - we don't track size independently? Seems like it might make a worthwhile addition, as well as convenience functions for efficiently adding/removing a member at either end of the list. (But we already know that the QObject hierarchy is silly with some of the things it does)= =2E --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --srIR8fR7svFnNJQ7U4W2JgW8WqvqBUpGR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWT1ktAAoJEKeha0olJ0NqC4sH/R7uvC3vGXgtup6yhMfvkURJ FsLuXHpMg4EjjkQV0fPeQHBAETASYr2yApC0phWrkVI51tuayY7s4p8xc+h9oiCD PClRwJODFrTNbXr1cseSWPAIIrqArRz4imEsK4Zf6jT9POUtfw/wkrw173OqCisl 0KmCOG5sdHvrQJ+nNNN0/aHjOUkfusRL576HwUULn0spsEg/QYmQoASIPWvrVlqt nFzL3i9Ka7H2TIAT9yLy1AI+k2k9g9x1uUrN3ws+/p/7mL3IaV4idR1S/KYhz0Wz +tzoINSuAPsVGaw/zy5Purw9NRZ7oJx+0+XQO1zv0SJ5Er5NW/SqKZu4pMTqu2o= =3iiM -----END PGP SIGNATURE----- --srIR8fR7svFnNJQ7U4W2JgW8WqvqBUpGR--