diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-22 21:19:27 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-01-24 18:35:22 +0100 |
commit | 817800ad39df10ca78e2c965a61d4d2025df622b (patch) | |
tree | c47b9d29de7ac3e3b75113cc3cd613301059fb32 /tests | |
parent | 508b1fa173e135c839f07e0e4cd6009ac63a577c (diff) |
Fix QXmlStreamReader parsing of files containing NULs
Due to a flaw in the internal API, QXmlStreamReader's internal buffering
would mistake a NUL byte in the input stream for EOF during parsing, but
wouldn't set atEnd == true because it hadn't yet processed all bytes.
This resulted in an infinite loop in QXmlStreamReaderPrivate::parse.
So, instead of returning zero (false) to indicate EOF, return -1 (but in
unsigned form, ~0, to avoid ICC warnings of change of sign). In turn,
this required enlarging a few variables to avoid ~0U becoming 0xffff,
which is a valid QChar (could happen if the input is a QString, not a
QIODevice).
Task-number: QTBUG-43513
Change-Id: If5badcfd3e4176b79517da1fd108e0abb93a3fd1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'tests')
18 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.ref b/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.ref new file mode 100644 index 0000000000..b636d80294 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.ref @@ -0,0 +1,3 @@ +StartDocument( ) +Invalid( processingInstructionTarget="xml_" ) +ERROR: Invalid XML character. diff --git a/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.xml b/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.xml Binary files differnew file mode 100644 index 0000000000..e87bf56453 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul0.ref b/tests/auto/corelib/xml/qxmlstream/data/nul0.ref new file mode 100644 index 0000000000..a76455ee07 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul0.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Premature end of document. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul0.xml b/tests/auto/corelib/xml/qxmlstream/data/nul0.xml Binary files differnew file mode 100644 index 0000000000..f76dd238ad --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul0.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul1.ref b/tests/auto/corelib/xml/qxmlstream/data/nul1.ref new file mode 100644 index 0000000000..a76455ee07 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul1.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Premature end of document. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul1.xml b/tests/auto/corelib/xml/qxmlstream/data/nul1.xml Binary files differnew file mode 100644 index 0000000000..aab3ad6ca9 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul1.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul2.ref b/tests/auto/corelib/xml/qxmlstream/data/nul2.ref new file mode 100644 index 0000000000..08bbcc6aa4 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul2.ref @@ -0,0 +1,3 @@ +StartDocument( ) +Invalid( ) +ERROR: Expected '[a-zA-Z]', but got ' '. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul2.xml b/tests/auto/corelib/xml/qxmlstream/data/nul2.xml Binary files differnew file mode 100644 index 0000000000..e14d1b8ae5 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul2.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul3.ref b/tests/auto/corelib/xml/qxmlstream/data/nul3.ref new file mode 100644 index 0000000000..cf4dd3848b --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul3.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Expected 'version', but got ''. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul3.xml b/tests/auto/corelib/xml/qxmlstream/data/nul3.xml Binary files differnew file mode 100644 index 0000000000..d8260b908e --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul3.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul3bis.ref b/tests/auto/corelib/xml/qxmlstream/data/nul3bis.ref new file mode 100644 index 0000000000..cf4dd3848b --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul3bis.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Expected 'version', but got ''. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul3bis.xml b/tests/auto/corelib/xml/qxmlstream/data/nul3bis.xml Binary files differnew file mode 100644 index 0000000000..61e011014e --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul3bis.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4.ref b/tests/auto/corelib/xml/qxmlstream/data/nul4.ref new file mode 100644 index 0000000000..cf4dd3848b --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul4.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Expected 'version', but got ''. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4.xml b/tests/auto/corelib/xml/qxmlstream/data/nul4.xml Binary files differnew file mode 100644 index 0000000000..90f20eebf0 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul4.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4bis.ref b/tests/auto/corelib/xml/qxmlstream/data/nul4bis.ref new file mode 100644 index 0000000000..cf4dd3848b --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul4bis.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Expected 'version', but got ''. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4bis.xml b/tests/auto/corelib/xml/qxmlstream/data/nul4bis.xml Binary files differnew file mode 100644 index 0000000000..15d2d10685 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul4bis.xml diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul5.ref b/tests/auto/corelib/xml/qxmlstream/data/nul5.ref new file mode 100644 index 0000000000..9432b74a99 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul5.ref @@ -0,0 +1,3 @@ +StartDocument( documentVersion="1.0" ) +Invalid( ) +ERROR: Start tag expected. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul5.xml b/tests/auto/corelib/xml/qxmlstream/data/nul5.xml Binary files differnew file mode 100644 index 0000000000..6a79cbdc75 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul5.xml |