Fix possible heap corruption in QXmlStream
authorAllan Sandfeld Jensen <allan.jensen@qt.io>
Mon, 13 Aug 2018 13:29:16 +0000 (15:29 +0200)
committerFelix Geyer <fgeyer@debian.org>
Sun, 14 Jul 2019 10:19:27 +0000 (11:19 +0100)
The value of 'tos' at the check might already be on the last element,
so triggering stack expansion on the second last element is too late.

Change-Id: Ib3ab2662d4d27a71effe9e988b9e172923af2908
Reviewed-by: Richard J. Moore <rich@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Gbp-Pq: Name CVE-2018-15518.patch

src/corelib/xml/qxmlstream_p.h

index 3539e1b7bf02f68797a1d4e086ec33dae7148d1c..f637e2d5a7c8e1e374e5c8be4f9dc15992f63ab0 100644 (file)
@@ -1242,7 +1242,7 @@ bool QXmlStreamReaderPrivate::parse()
             state_stack[tos] = 0;
             return true;
         } else if (act > 0) {
-            if (++tos == stack_size-1)
+            if (++tos >= stack_size-1)
                 reallocateStack();
 
             Value &val = sym_stack[tos];