]> git.proxmox.com Git - mirror_qemu.git/commit
qjson: Limit number of tokens in addition to total size
authorMarkus Armbruster <armbru@redhat.com>
Wed, 25 Nov 2015 21:23:33 +0000 (22:23 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 26 Nov 2015 09:07:07 +0000 (10:07 +0100)
commitdf649835fe48f635a93316fdefe96ced7189316e
tree5460f95750d89543d73be1b7c125260f1d8e9f47
parent9bada8971173345ceb37ed1a47b00a01a4dd48cf
qjson: Limit number of tokens in addition to total size

Commit 29c75dd "json-streamer: limit the maximum recursion depth and
maximum token count" attempts to guard against excessive heap usage by
limiting total token size (it says "token count", but that's a lie).

Total token size is a rather imprecise predictor of heap usage: many
small tokens use more space than few large tokens with the same input
size, because there's a constant per-token overhead: 37 bytes on my
system.

Tighten this up: limit the token count to 2Mi.  Chosen to roughly
match the 64MiB total token size limit.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1448486613-17634-13-git-send-email-armbru@redhat.com>
qobject/json-streamer.c