qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH] json: Fix to reject duplicate object member names
Date: Thu, 6 Dec 2018 13:50:08 +0100	[thread overview]
Message-ID: <fa022957-1015-9173-6e17-c683f1a39392@redhat.com> (raw)
In-Reply-To: <20181206121743.20762-1-armbru@redhat.com>

On 12/6/18 1:17 PM, Markus Armbruster wrote:
> The JSON parser happily accepts duplicate object member names.  The
> last value wins.  Reproducer #1:
> 
>     $ qemu-system-x86_64 -qmp stdio
>     {"QMP": {"version": {"qemu": {"micro": 93, "minor": 0, "major": 3},
>     "package": "v3.1.0-rc3-7-g87a45d86ed"}, "capabilities": []}}
>     {'execute':'qmp_capabilities'}
>     {"return": {}}
>     {'execute':'blockdev-add','arguments':{'driver':'null-co',
>      'node-name':'foo','node-name':'bar'}}
>     {"return": {}}
>     {'execute':'query-named-block-nodes'}
>     {"return": [{ [...] "node-name": "bar" [...] }]}
> 
> Reproducer #2 is iotest 229.
> 
> Fix the parser to reject duplicates, and fix iotest 229 not to use
> them.

Looks like 2 different patches.

> 
> Reported-by: Max Reitz <mreitz@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  qobject/json-parser.c  | 5 +++++
>  tests/qemu-iotests/229 | 1 -
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/qobject/json-parser.c b/qobject/json-parser.c
> index 5a840dfd86..a86de3f462 100644
> --- a/qobject/json-parser.c
> +++ b/qobject/json-parser.c
> @@ -288,6 +288,11 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict)
>          goto out;
>      }
>  
> +    if (qdict_haskey(dict, qstring_get_str(key))) {
> +        parse_error(ctxt, token, "duplicate key");
> +        goto out;
> +    }
> +        
>      qdict_put_obj(dict, qstring_get_str(key), value);
>  
>      qobject_unref(key);
> diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229
> index 86602437ff..893d098ad2 100755
> --- a/tests/qemu-iotests/229
> +++ b/tests/qemu-iotests/229
> @@ -69,7 +69,6 @@ echo
>  _send_qemu_cmd $QEMU_HANDLE \
>      "{'execute': 'drive-mirror',
>                   'arguments': {'device': 'testdisk',
> -                               'mode':   'absolute-paths',
>                                 'format': '$IMGFMT',
>                                 'target': '$DEST_IMG',
>                                 'sync':   'full',
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

  parent reply	other threads:[~2018-12-06 12:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06 12:17 [Qemu-devel] [PATCH] json: Fix to reject duplicate object member names Markus Armbruster
2018-12-06 12:20 ` Daniel P. Berrangé
2018-12-06 12:50 ` Philippe Mathieu-Daudé [this message]
2018-12-06 13:11   ` Markus Armbruster
2018-12-06 13:11 ` no-reply
2018-12-13  8:57 ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa022957-1015-9173-6e17-c683f1a39392@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).