]> git.ipfire.org Git - thirdparty/qemu.git/commit
json: Reject invalid UTF-8 sequences
authorMarkus Armbruster <armbru@redhat.com>
Thu, 23 Aug 2018 16:39:49 +0000 (18:39 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 24 Aug 2018 18:26:37 +0000 (20:26 +0200)
commite59f39d40397645477b959255aedfa17a7c9c779
tree9d1bbd816632aa79e9015ddd47eb7a827b1787f0
parenta89d3104a29c400dfed4b675d6385a17223f9e0f
json: Reject invalid UTF-8 sequences

We reject bytes that can't occur in valid UTF-8 (\xC0..\xC1,
\xF5..\xFF in the lexer.  That's insufficient; there's plenty of
invalid UTF-8 not containing these bytes, as demonstrated by
check-qjson:

* Malformed sequences

  - Unexpected continuation bytes

  - Missing continuation bytes after start bytes other than
    \xC0..\xC1, \xF5..\xFD.

* Overlong sequences with start bytes other than \xC0..\xC1,
  \xF5..\xFD.

* Invalid code points

Fixing this in the lexer would be bothersome.  Fixing it in the parser
is straightforward, so do that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180823164025.12553-23-armbru@redhat.com>
include/qemu/unicode.h
qobject/json-parser.c
tests/check-qjson.c
util/unicode.c