All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 00/60] json: Fixes, error reporting improvements, cleanups
@ 2018-08-17 15:04 Markus Armbruster
  2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 01/60] check-qjson: Cover multiple JSON objects in same string Markus Armbruster
                   ` (60 more replies)
  0 siblings, 61 replies; 91+ messages in thread
From: Markus Armbruster @ 2018-08-17 15:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, mdroth, eblake

JSON is such a simple language, so writing a parser should be easy,
shouldn't it?  Well, the evidence is in, and it's a lot of patches.
Summary of fixes:

* Reject ASCII control characters in strings as RFC 7159 specifies

* Reject all invalid UTF-8 sequences, not just some

* Reject invalid \uXXXX escapes

* Implement \uXXXX surrogate pairs as specified by RFC 7159

* Don't ignore \u0000 silently, map it to \xC0\80 (modified UTF-8)

* qobject_from_json() is ridicilously broken for input containing more
  than one value, fix

* Don't ignore trailing unterminated structures

* Less cavalierly cruel error reporting

Topped off with tests and cleanups.

If you're into this kind of disaster relief, commit c7a3f25200c
"qapi.py: Restructure lexer and parser" was even funnier.

This v2 is unlikely to be final: I added three more patches, and
addressed a lot of review comments.  I should also update references
to RFC 7159 to RFC 8259.  But right now this needs to get out for
another round of review.

v2:
* Rebased
* PATCH 01,11-14,16-18,20,22-23,29-36,41,43,45-50,53-55 otherwise
  unchanged
* PATCH 57-60 are new
* R-bys kept unless noted otherwise
* PATCH 02
  - Cover unrecognized keyword [Eric]
* PATCH 03
  - Cover \r [Eric]
* PATCH 04-05
  - Comments touched up [Eric]
* PATCH 06
  - Use qmp_fd_send_raw() just for "\xff" [Eric]
* PATCH 07
  - Plug memory leak [Eric]
* PATCH 08
  - Delay adding coverage for \' until PATCH 09
* PATCH 09
  - Cover \\\0
  - Drop duplicated test case (editing accident) [Eric]
  - Improve surrogate coverage
* PATCH 10
  - Don't lose test coverage for \" and \'
  - R-by dropped
* PATCH 15,27,38-39
  - Cover unkown interpolation specification
  - Cover attempt to interpolate into JSON string
  - R-by of PATCH 15 dropped
* PATCH 19
  - Tweak loop control once more
  - R-by dropped
* PATCH 21,26
  - Update for tweak to PATCH 19
  - I might still drop redundant masking [Eric]
* PATCH 24
  - Commit message improved
* PATCH 25
  - Comment improvement [Eric]
  - Commit message tweaked
* PATCH 28
  - Fix error message to show both halves of an invalid surrogate pair
    [Eric]
  - Fix unpaired leading surrogate followed by \u escape [Paolo]
* PATCH 36
  - I might still rename JSON_INTERPOL & friends [Eric]
* PATCH 37
  - Document lexing interpolations is now optional [Eric]
  - Move deletion of a redundant assignment from PATCH 51 [Eric]
* PATCH 37,42,51-52
  - De-duplicate state transitions common to IN_START and
    IN_START_INTERPOL [Eric]
* PATCH 38
  - Commit message tweaked
* PATCH 39
  - More legible commit message [Eric]
  - Comment fix [Eric]
* PATCH 40
  - Commit message typo [Eric]
* PATCH 44
  - Commit message tab damage [Eric]
* PATCH 56
  - More on QGA synchronization [Eric]
  - I might still move this earlier in the series

Marc-André Lureau (2):
  json: remove useless return value from lexer/parser
  json-parser: simplify and avoid JSONParserContext allocation

Markus Armbruster (58):
  check-qjson: Cover multiple JSON objects in same string
  check-qjson: Cover blank and lexically erroneous input
  check-qjson: Cover whitespace more thoroughly
  qmp-cmd-test: Split off qmp-test
  qmp-test: Cover syntax and lexical errors
  test-qga: Clean up how we test QGA synchronization
  check-qjson: Cover escaped characters more thoroughly, part 1
  check-qjson: Streamline escaped_string()'s test strings
  check-qjson: Cover escaped characters more thoroughly, part 2
  check-qjson: Consolidate partly redundant string tests
  check-qjson: Cover UTF-8 in single quoted strings
  check-qjson: Simplify utf8_string()
  check-qjson: Fix utf8_string() to test all invalid sequences
  check-qjson qmp-test: Cover control characters more thoroughly
  check-qjson: Cover interpolation more thoroughly
  json: Fix lexer to include the bad character in JSON_ERROR token
  json: Reject unescaped control characters
  json: Revamp lexer documentation
  json: Tighten and simplify qstring_from_escaped_str()'s loop
  check-qjson: Document we expect invalid UTF-8 to be rejected
  json: Reject invalid UTF-8 sequences
  json: Report first rather than last parse error
  json: Leave rejecting invalid UTF-8 to parser
  json: Accept overlong \xC0\x80 as U+0000 ("modified UTF-8")
  json: Leave rejecting invalid escape sequences to parser
  json: Simplify parse_string()
  json: Reject invalid \uXXXX, fix \u0000
  json: Fix \uXXXX for surrogate pairs
  check-qjson: Fix and enable utf8_string()'s disabled part
  json: Have lexer call streamer directly
  json: Redesign the callback to consume JSON values
  json: Don't pass null @tokens to json_parser_parse()
  json: Don't create JSON_ERROR tokens that won't be used
  json: Rename token JSON_ESCAPE & friends to JSON_INTERPOL
  json: Treat unwanted interpolation as lexical error
  json: Pass lexical errors and limit violations to callback
  json: Leave rejecting invalid interpolation to parser
  json: Replace %I64d, %I64u by %PRId64, %PRIu64
  json: Nicer recovery from invalid leading zero
  json: Improve names of lexer states related to numbers
  qjson: Fix qobject_from_json() & friends for multiple values
  json: Fix latent parser aborts at end of input
  json: Fix streamer not to ignore trailing unterminated structures
  json: Assert json_parser_parse() consumes all tokens on success
  qjson: Have qobject_from_json() & friends reject empty and blank
  json: Enforce token count and size limits more tightly
  json: Streamline json_message_process_token()
  json: Unbox tokens queue in JSONMessageParser
  json: Eliminate lexer state IN_ERROR and pseudo-token JSON_MIN
  json: Eliminate lexer state IN_WHITESPACE, pseudo-token JSON_SKIP
  json: Make JSONToken opaque outside json-parser.c
  qobject: Drop superfluous includes of qemu-common.h
  json: Clean up headers
  docs/interop/qmp-spec: How to force known good parser state
  tests/drive_del-test: Fix harmless JSON interpolation bug
  json: Keep interpolation state in JSONParserContext
  json: Improve safety of qobject_from_jsonf_nofail() & friends
  json: Support %% in JSON strings when interpolating

 MAINTAINERS                      |    1 +
 block.c                          |    5 -
 docs/interop/qmp-spec.txt        |   42 +-
 include/qapi/qmp/json-lexer.h    |   56 --
 include/qapi/qmp/json-parser.h   |   36 +-
 include/qapi/qmp/json-streamer.h |   46 --
 include/qapi/qmp/qerror.h        |    3 -
 include/qemu/unicode.h           |    1 +
 monitor.c                        |   21 +-
 qapi/qmp-dispatch.c              |    1 -
 qapi/qobject-input-visitor.c     |    5 -
 qga/main.c                       |   15 +-
 qobject/json-lexer.c             |  354 +++++-----
 qobject/json-parser-int.h        |   51 ++
 qobject/json-parser.c            |  377 +++++------
 qobject/json-streamer.c          |  126 ++--
 qobject/qbool.c                  |    1 -
 qobject/qjson.c                  |   31 +-
 qobject/qlist.c                  |    1 -
 qobject/qnull.c                  |    1 -
 qobject/qnum.c                   |    1 -
 qobject/qobject.c                |    1 -
 qobject/qstring.c                |    1 -
 tests/Makefile.include           |    3 +
 tests/check-qjson.c              | 1058 ++++++++++++++++--------------
 tests/drive_del-test.c           |    8 +-
 tests/libqtest.c                 |   57 +-
 tests/libqtest.h                 |   13 +
 tests/qmp-cmd-test.c             |  213 ++++++
 tests/qmp-test.c                 |  252 ++-----
 tests/test-qga.c                 |    3 +-
 util/unicode.c                   |   69 +-
 32 files changed, 1495 insertions(+), 1358 deletions(-)
 delete mode 100644 include/qapi/qmp/json-lexer.h
 delete mode 100644 include/qapi/qmp/json-streamer.h
 create mode 100644 qobject/json-parser-int.h
 create mode 100644 tests/qmp-cmd-test.c

-- 
2.17.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

end of thread, other threads:[~2018-08-21  5:11 UTC | newest]

Thread overview: 91+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-17 15:04 [Qemu-devel] [PATCH v2 00/60] json: Fixes, error reporting improvements, cleanups Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 01/60] check-qjson: Cover multiple JSON objects in same string Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 02/60] check-qjson: Cover blank and lexically erroneous input Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 03/60] check-qjson: Cover whitespace more thoroughly Markus Armbruster
2018-08-17 15:48   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 04/60] qmp-cmd-test: Split off qmp-test Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 05/60] qmp-test: Cover syntax and lexical errors Markus Armbruster
2018-08-17 15:51   ` Eric Blake
2018-08-20  8:34     ` Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 06/60] test-qga: Clean up how we test QGA synchronization Markus Armbruster
2018-08-17 15:52   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 07/60] check-qjson: Cover escaped characters more thoroughly, part 1 Markus Armbruster
2018-08-17 16:22   ` Eric Blake
2018-08-20  9:16     ` Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 08/60] check-qjson: Streamline escaped_string()'s test strings Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 09/60] check-qjson: Cover escaped characters more thoroughly, part 2 Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 10/60] check-qjson: Consolidate partly redundant string tests Markus Armbruster
2018-08-17 16:23   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 11/60] check-qjson: Cover UTF-8 in single quoted strings Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 12/60] check-qjson: Simplify utf8_string() Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 13/60] check-qjson: Fix utf8_string() to test all invalid sequences Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 14/60] check-qjson qmp-test: Cover control characters more thoroughly Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 15/60] check-qjson: Cover interpolation " Markus Armbruster
2018-08-17 16:26   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 16/60] json: Fix lexer to include the bad character in JSON_ERROR token Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 17/60] json: Reject unescaped control characters Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 18/60] json: Revamp lexer documentation Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 19/60] json: Tighten and simplify qstring_from_escaped_str()'s loop Markus Armbruster
2018-08-17 16:26   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 20/60] check-qjson: Document we expect invalid UTF-8 to be rejected Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 21/60] json: Reject invalid UTF-8 sequences Markus Armbruster
2018-08-17 16:29   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 22/60] json: Report first rather than last parse error Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 23/60] json: Leave rejecting invalid UTF-8 to parser Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 24/60] json: Accept overlong \xC0\x80 as U+0000 ("modified UTF-8") Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 25/60] json: Leave rejecting invalid escape sequences to parser Markus Armbruster
2018-08-17 16:32   ` Eric Blake
2018-08-20  8:44     ` Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 26/60] json: Simplify parse_string() Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 27/60] json: Reject invalid \uXXXX, fix \u0000 Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 28/60] json: Fix \uXXXX for surrogate pairs Markus Armbruster
2018-08-17 16:36   ` Eric Blake
2018-08-20  8:40     ` Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 29/60] check-qjson: Fix and enable utf8_string()'s disabled part Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 30/60] json: remove useless return value from lexer/parser Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 31/60] json-parser: simplify and avoid JSONParserContext allocation Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 32/60] json: Have lexer call streamer directly Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 33/60] json: Redesign the callback to consume JSON values Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 34/60] json: Don't pass null @tokens to json_parser_parse() Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 35/60] json: Don't create JSON_ERROR tokens that won't be used Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 36/60] json: Rename token JSON_ESCAPE & friends to JSON_INTERPOL Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 37/60] json: Treat unwanted interpolation as lexical error Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 38/60] json: Pass lexical errors and limit violations to callback Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 39/60] json: Leave rejecting invalid interpolation to parser Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 40/60] json: Replace %I64d, %I64u by %PRId64, %PRIu64 Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 41/60] json: Nicer recovery from invalid leading zero Markus Armbruster
2018-08-17 16:03   ` Eric Blake
2018-08-20 11:39     ` Markus Armbruster
2018-08-20 18:36       ` Eric Blake
2018-08-21  5:10         ` Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 42/60] json: Improve names of lexer states related to numbers Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 43/60] qjson: Fix qobject_from_json() & friends for multiple values Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 44/60] json: Fix latent parser aborts at end of input Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 45/60] json: Fix streamer not to ignore trailing unterminated structures Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 46/60] json: Assert json_parser_parse() consumes all tokens on success Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 47/60] qjson: Have qobject_from_json() & friends reject empty and blank Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 48/60] json: Enforce token count and size limits more tightly Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 49/60] json: Streamline json_message_process_token() Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 50/60] json: Unbox tokens queue in JSONMessageParser Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 51/60] json: Eliminate lexer state IN_ERROR and pseudo-token JSON_MIN Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 52/60] json: Eliminate lexer state IN_WHITESPACE, pseudo-token JSON_SKIP Markus Armbruster
2018-08-17 16:07   ` Eric Blake
2018-08-20 11:51     ` Markus Armbruster
2018-08-20 18:38       ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 53/60] json: Make JSONToken opaque outside json-parser.c Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 54/60] qobject: Drop superfluous includes of qemu-common.h Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 55/60] json: Clean up headers Markus Armbruster
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 56/60] docs/interop/qmp-spec: How to force known good parser state Markus Armbruster
2018-08-17 16:42   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 57/60] tests/drive_del-test: Fix harmless JSON interpolation bug Markus Armbruster
2018-08-17 16:43   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 58/60] json: Keep interpolation state in JSONParserContext Markus Armbruster
2018-08-17 18:09   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 59/60] json: Improve safety of qobject_from_jsonf_nofail() & friends Markus Armbruster
2018-08-17 18:14   ` Eric Blake
2018-08-17 15:05 ` [Qemu-devel] [PATCH v2 60/60] json: Support %% in JSON strings when interpolating Markus Armbruster
2018-08-17 18:18   ` Eric Blake
2018-08-18 10:02 ` [Qemu-devel] [PATCH v2 00/60] json: Fixes, error reporting improvements, cleanups no-reply
2018-08-20  8:31   ` Markus Armbruster
2018-08-20  8:42     ` Fam Zheng
2018-08-20 11:59       ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.