summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-04-14 22:13:32 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-04-16 10:08:32 +0000
commit38e111158a38507c63fd70f9ee18b9116b537976 (patch)
tree55a48ec4873f2a71ed37d65a408aec6027e61c4c
parent930e59b798d9e3d08e17440980d33a08fb411cbe (diff)
Don't parse XML symbols longer than 4096 characters
It is slow and will use too much memory. Pick-to: 6.1 6.1.0 6.0 5.15 Fixes: QTBUG-91889 Change-Id: I45c5e6038357c87bbb85b1ace17ef39a2a814ea0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/serialization/qxmlstream.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp
index 769b33931e..5f9bed99b8 100644
--- a/src/corelib/serialization/qxmlstream.cpp
+++ b/src/corelib/serialization/qxmlstream.cpp
@@ -1297,6 +1297,11 @@ inline int QXmlStreamReaderPrivate::fastScanName(int *prefix)
int n = 0;
uint c;
while ((c = getChar()) != StreamEOF) {
+ if (n >= 4096) {
+ // This is too long to be a sensible name, and
+ // can exhaust memory
+ return 0;
+ }
switch (c) {
case '\n':
case ' ':