summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-09-02 11:11:25 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-09-06 16:23:01 -0700
commitb6314409028c8407645e694d6c6b2b9b8c6c6447 (patch)
tree1ef48c1e594cc217319ab8bcd7eace80e5379010 /src
parent248828b9a3562fc23ac1d39733aaf07a83584dc4 (diff)
JSON parsing: fix incorrect sign-extension for decoding bad escapes
The parser was lenient in accepting backslashes followed by invalid characters, but accidentally sign-extended everything above 0x7f causing broken outputs that weren't valid UTF-16 either. For example, the sequence "\\\xff" (backslash followed by 0xff) produced sequence "\ud7bf\udfff" (U+D7BF is not a surogate pair). Change-Id: Ie72b0dd0fbe84d2caae0fffd16a113c703a7696f Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/serialization/qjsonparser.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp
index 9760fde2ed..5dc2a30915 100644
--- a/src/corelib/serialization/qjsonparser.cpp
+++ b/src/corelib/serialization/qjsonparser.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -787,7 +787,7 @@ static inline bool scanEscapeSequence(const char *&json, const char *end, char32
return false;
DEBUG << "scan escape" << (char)*json;
- uint escaped = *json++;
+ uchar escaped = *json++;
switch (escaped) {
case '"':
*ch = '"'; break;