Debian Patches

Status for qt6-5compat/6.11.2-5

Patch Description Author Forwarded Bugs Origin Last update
upstream_d0cd01d_CVE-2026-101201.diff QBinaryJson: prevent OOB read in fromBinaryData()
The fromBinaryData() function computes the document bound in
size_t, but then truncates it to uint. As a result, when
provided a malformed binary json with root.size in the range of
[0xFFFFFFF8, 0xFFFFFFFF], the total size overflows to the values
between 0 and 7, and the size check incorrectly passes.
When combined with a malicious tableOffset, this results in an
out-of-bounds read in the range of up to 4 GiB past the end of
the allocated buffer - depending on the memory layout it can
lead to either a crash or a read of some potentially sensitive
data.

Do the calculations in uint and use qAddOverflow() to detect
overflows. Since the underlying data structure uses uint to
store the size of the allocated data, we can simply return
early if we detect an overflow.

The newly-added test creates a larger buffer and copies a correct
binary json blob there. Then it injects the malformed size of the
payload and a new offset of the data table, together with the new
table. Then the test uses this large buffer to demonstrate an
out-of-bounds read on a modified blob. If the data was not backed
by a large buffer, it would have been an out-of-bounds read.

The fromRawData() method is not affected (assuming that the passed
size is correct), because it uses the input size parameter
directly, without analyzing the internal structure of the binary
json blob.

(cherry picked from commit c0a495894d83a3c48055bd1e544f93147fc6ade1)
(cherry picked from commit 173cc93ec160719dfb0268971ba16e4e8f46dc57)
Ivan Solovev <ivan.solovev@qt.io> no 2026-08-10
upstream_6a61c85_CVE-2026-101201.diff QBinaryJson::fromBinaryData(): do the comparison in size_t
In Qt 6, the QBA can actually store more than UINT_MAX bytes, so
casting to uint can truncate. Use size_t instead.

Amends the port of Qt container size_type form int to qsizetype
(Qt 6.0).

(cherry picked from commit 721ed576391211ca53ecdaaecf6dd41df7bc962e)
(cherry picked from commit 897a3421f925cb73409d3138d464b8c0ab30d15d)
Ivan Solovev <ivan.solovev@qt.io> no 2026-08-11
upstream_CVE-2026-107472.diff QTextCodec: fix OOB read in TSCII codec
The TSCII codec iterates over the input buffer, and if the currently
processed QChar is not ASCII (has a value larger than 0x80), tries to
analyze the next two QChars.
The problem is that it does so without validating the i + 1 and i + 2
indices against the input length. As a result, if it can try to read
up to two QChars past the end of the input buffer.

The test is crafted in such way, that a larger buffer is passed as an
input, so it does not trigger ASAN in case of failure, but rather
simply reports an invalid result.

Note that the else branch in the code that now records an error could
instead save the trailing QChar in the converter state, so that the
following chunk could decode it properly.
But this patch does not try to fix the correctness of the encoding, it
simply eliminates the read past the end of the input buffer.


(cherry picked from commit 5841a625142199bf3c58e6ace6fa2c4a8a2c5254)
(cherry picked from commit 9b5b9a57e72c9d69197b99ab4a3939833d334377)
Ivan Solovev <ivan.solovev@qt.io> no 2026-08-21
upstream_CVE-2026-107479.diff QTextCodec: fix silent truncation of input data to int
The QTextCodec APIs did not account for the fact that QStringView,
QString, and QByteArray uses qsizetype, not int, to represent its
size.

As a result, the size is silently truncated when passing to the
underlying API, which can produce negative values for inputs
larger than INT_MAX. This can lead to all sorts of surprising
results, depending on the codec implementation.

Fix by explicitly checking the input size against INT_MAX. Raise
a warning and return early if the size is greater than this value.

The toUnicode(const char *) overload is special. It is using qstrlen()
to calculate the input size.
The qstrlen() method returns size_t (or uint in 5.15), which is then
truncated to int, and we get the same problem.

Since qstrlen() in 5.15 is broken (returning uint instead of size_t),
fix by using strlen() directly and comparing the result against
INT_MAX. Raise a warning and return early if the size is greater than
this value.

We could theoretically rewrite the code to do the conversion in a loop,
but since it is a compatibility code, the valid usecases are supposed
to use is with inputs less than INT_MAX anyway. If it is required to
deal with a larger input, the chunking can be implemented at the user
side.

[ChangeLog][QTextCodec] Fixed a bug in toUnicode(), fromUnicode(),
and canEncode() methods that could silently truncate the size of
input data if it exceeded INT_MAX. The updated code now raises a
warning and returns an empty QString/QByteArray immediately. To
process long inputs, implement chunking of the input data on the
client side, using the toUnicode() and fromUnicode() overloads that
take the ConverterState as the last parameter.

(cherry picked from commit 8631aea33f3de13c23fcd740d8900c775c18ac00)
(cherry picked from commit aff163c0589bd3c089ab0fe5cfc8a8708319fdc9)
Ivan Solovev <ivan.solovev@qt.io> no 2026-08-24
upstream_CVE-2026-107590.diff QTextCodec: fix OOB write in ICONV codec
The ICONV codec has a size miscalculation error when encoding continues
with a high surrogate kept in the state after encoding of the previous
chunk. The code was requesting a resize based on the length in UTF-16
code points instead of the length in bytes.
As a result, we were requesting half of the bytes that we actually
needed.
Note that since resize() allocates more than requested, the code could
sometimes execute successfully.

The test specifically adds a large tail to the input, so that memcpy()
clearly triggers an out-of-bounds write. The test was triggering ASAN
before the fix.


(cherry picked from commit cf3f5fbc8bae37cd358b8157cff11b329cca02aa)
(cherry picked from commit 724025a7c05596961cc870ef703a2f2b14e55c88)
Ivan Solovev <ivan.solovev@qt.io> no 2026-08-21
upstream_CVE-2026-100140_1.diff SAX: use ranged-for loops
In places where we do not need the index.
It is the part of porting the code from int to qsizetype.

(cherry picked from commit 6cae8a4aebc82fb59116d55a551c168b2cd9e053)
(cherry picked from commit 2a41143bbae0f3a11f6f949aba164854d29dd4de)
Ivan Solovev <ivan.solovev@qt.io> no 2026-09-09
upstream_CVE-2026-100140_2.diff SAX: port internal implementation to qsizetype
The implementation was using int when referring to QString/QByteArray
sizes and indices. Use qsizetype consistently. These were all
overlooked when moving the code from Qt 5 to Qt5Compat module of
Qt 6.

This patch fixes at least one significant issue: a write past the
end of the buffer in updateValue().

The static updateValue() method computes the new length of the
underlying buffer by doing an addition of two int values without an
overflow check.

As a result, for XML documents with large strings in names, values, or
references, the calculation can overflow to a negative value. This
negative value will be passed to QString::resize(), which will result
in an empty string.

After that, we immediately call memcpy() into that string, passing the
original offset and the size of the new chunk - this will cause a write
past the end of the (empty) buffer.

Note that in practice this is not a problem in Qt 5 and 32-bit builds
of Qt 6, because in that cases QString cannot really contain INT_MAX
QChars (it is limited to INT_MAX *bytes*). So, we'll get a memory
allocation error faster than an int overflow and write past the end
of the buffer.

Get rid of storing the string size in a separate variable, and use
QString::size() in the updateValue() method, which returns the size
as qsizetype. This means that the next resize() call also computes
the new value as qsizetype.

After switching to qsizetype, the code would fail to allocate earlier
than an overflow would happen. This is in line with how all Qt
containers behave.

The unit-test generates a string with over 2 Gi of charactes and
makes sure that they all are properly parsed.
Due to the fact that the parser builds the internal buffers in chunks
of 256 QChars, and also because of the fact that the test actually
allocates at least 4 GiB of memory, we do not run it on CI.

(cherry picked from commit 4b72520e50cd04f2c29524f28bf77eefc81956fe)
(cherry picked from commit 78a07281b53f7fcdb796a995face2cd725c63d5b)
Ivan Solovev <ivan.solovev@qt.io> no 2026-09-09
upstream_CVE-2026-100140_3.diff SAX: avoid integer truncation when reporting column and line
We ported the internal implementation to qsizetype, but the public API
of QXmlLocator still reports the column and line as int.

To avoid integer truncation when reporting results, explicitly check
if the reported value is larger than INT_MAX and report -1 if it is.
This is in line with the documentation, which explicitly states that -1
is returned when no column/line number is available.

(cherry picked from commit 0d2c086cb8cfa6833b82abb200b53a51a0321bdf)
(cherry picked from commit cdcff89d7b479792e47d25f1cd50be840301a11c)
Ivan Solovev <ivan.solovev@qt.io> no 2026-09-09
upstream_CVE-2026-100140_4.diff QXmlAttributes: do not allow more than INT_MAX attributes
The implementation stores the attributes in a QList, meaning that its
size is represented as qsizetype.

However, the public API, like index() and length() only returns int.
This may lead to a (very unlikely in practice) situation when some of
the parsed attributes are not accessible to the user.

To avoid such situations, this patch limits the amount of attributes
for a single element to INT_MAX. If a document contains an element with
more than INT_MAX attibutes, it is considered malformed, and an error
is reported.

(cherry picked from commit a8def6219491537fd9dbdb74d98b8f67946ad82d)
(cherry picked from commit fabca46cfce444effee994794219e04bf6dcb8a7)
Ivan Solovev <ivan.solovev@qt.io> no 2026-09-09
upstream_CVE-2026-105925_0.diff QXmlSimpleReader: add tests that show unconstrained entity expansion
There is a single entityCharacterLimit limit (4096 characters), but it
is not checked consistently. As a result, the entity expansion can cause
an unbound memory allocation.

The tests also revealed that the existing entity size validation logic
depends on the order of entity declarations - if they're declared in
the reverse order, then entitiy expansion simply does not happen.

The tests do not aim to reach the OOM condition, but rather check that
the expansion exceeds the entityCharacterLimit.

Another set of tests covers references to standard XML entities,
numeric character references, references to undefined entities,
references to entities that have empty values, and entity loops.

They all are supposed to cover corner cases that might trigger
unconstrained entity expansions.

The unknown_entity_in_attlist testcase required to add an
overload of attributeDecl() to the custom handler. That is
required to make sure that the entity size check fails before
ATTLIST is expanded, not after the entire DTD is parsed.
Otherwise ATTLIST itself can be uset to exhaust memory.

(cherry picked from commit 82cccc5cd6842c51f0217842329a9961754a44c3)
(cherry picked from commit 43f9b65aa5f672634b14b3939a374e5857394e4d)
Ivan Solovev <ivan.solovev@qt.io> no 2026-09-01
upstream_CVE-2026-105925_1.diff QXmlSimpleReader: limit entity expansion size at expansion time
The old check calculated the expanded size of each internal general
entity when the entity was declared. That approach has several
problems:

- It does not support forward references. When an entity was declared,
its value was only searched for references to entities that were
already declared. A reference to an entity declared later stayed in
the value as plain text, and was counted as a few literal characters
forever. Declaring the entities in reverse order was enough to bypass
the limit.

- The expanded sizes were calculated once and cached, using whatever
sizes of the referenced entities happened to be known at that point
(which also depended on the hash iteration order). They were never
updated when more entities were declared.

- An entity that does not reference other entities was never checked,
so a single literal entity larger than the limit was accepted.

- At declaration time it is impossible to tell whether a reference to a
not-yet-declared entity is a forward reference or a reference to an
entity that will never be declared. That is only known once the DTD
is complete. However, entities can be expanded before that point,
in the default value of an attribute in an ATTLIST declaration.
Fixing this at declaration time would require tracking
unresolved references, re-running the calculation once the DTD ends,
and adding extra checks wherever an entity is expanded inside the
DTD. Propagating size updates through the unresolved entities can
also cost quadratic time on a crafted DTD.

Instead, count the size while the entities are actually being
expanded. All internal general entities are expanded through
insertXmlRef(), both in content and in attribute values (including
the default values in ATTLIST). Before an entity value is pushed to
the reference stack, update a counter for the outermost internal
general entity that is being expanded:

- if no other internal general entity is being expanded, this is the
outermost one, so restart the counter with the size of its value;
- if the reference comes from the value of the enclosing entity, the
"&name;" text was already counted as a part of that value, so
replace it with the size of the referenced value;
- if the reference comes from an external entity included by the
enclosing entity, its text was not counted, so add the full size of
the referenced value.

Parsing fails as soon as the counter exceeds the limit. This measures
the expanded size in the same way as before: references to unknown
entities, standard entities and character references are counted
with their literal size.

This approach is more robust:

- The order of declarations does not matter, because all entities are
known by the time they are expanded.
- There is no need to decide whether a reference is truly unknown.
The parser already resolves each reference when it gets to it, and
the counter only follows what actually gets expanded.
- It covers every place where an internal general entity is expanded,
including the ones inside the DTD, without a separate finalization
step.
- It costs O(1) per expansion and needs no bookkeeping for the
declared entities.

As a consequence, oversized entities are now rejected when they are
used, not when they are declared. An entity that is never referenced
is not checked. Also, the size is checked when a value is pushed, before
its own references are replaced, so a value that references an entity
shorter than its "&name;" text can be rejected even if its final
expansion would fit into the limit.

Update the dtdRecursionLimit() test accordingly: all four entities in
internal-entity-polynomial-attribute.xml are now declared before the
expansion in the attribute fails.

This fixes all tests cases that handle general entity expansion in the
entityExpansionLimit() test. Parameter entities are not covered by this
change, so the related test cases are still expected to fail.

The patch also adds a new test that checks the entity expansion limit
with an external entity resolver.

(cherry picked from commit b79352273c9a841efeddfa768646f0cc9e378a4d)
Ivan Solovev <ivan.solovev@qt.io> no 2026-10-06
upstream_CVE-2026-105925_3.diff QXmlSimpleReader: add parameter entity length checks
The earlier patches fixed the size checks for the expansion of general
entities.

However, the parser also processes parameter entities.
While the W3C spec forbids referencing parameter entities from
general entities or from other parameter entities in the internal
subset of DTD, the QXmlSimpleReader's parser historically allows
it.

We can try to follow the specification, and thus change the
behavior, or just introduce the same entitiy expanstion limits,
as applied to the general entities. I chose the second approach.

Parameter entities are expanded in two places in parsePEReference(),
and each of them needs a limit.
1. A parameter entity included in the DTD.
Its replacement text is parsed again, so it can contain further
parameter entity references, and general entity references in
default attribute values of ATTLIST declarations. A parameter
entity reference can even be created with "&#37;", which becomes a
plain '%' when the entity value is declared, and is only recognized
as a reference once the value is included in the DTD.
Handle it exactly like general entities: count the size in
insertXmlRef(). An internal parameter entity included in the DTD
starts the count of the outermost expansion, or continues it, and
every parameter or general entity expanded while it is on the
reference stack adds to the same counter. Replace the boolean
parameter of insertXmlRef() with an ExpansionCheck enum, so that
parameter entities can be reported with the '%' prefix in the error
message.
2. A parameter entity included in an entity value.
Here the thing that needs to be limited is the value that is being
built, not a single reference. That value is read from the
document, not from the reference stack, and each included parameter
entity is popped from the stack before the next reference is read.
The counter used for the expansions would therefore treat every
sibling reference in
<!ENTITY % b '%a;%a;%a;...'>
as a new outermost expansion, and restart counting each time.
Add a separate includedParameterEntitySize counter that sums up the
sizes of all parameter entities included in the entity value that is
currently being parsed, and reset it at the start of every entity
value.

Note that the first check will technically catch both cases. However,
it does not prevent the problem of a potentially uncontrolled expansion
of nested parameter entities - that's what the second check catches.

This fixes the remaining failing cases of the entityExpansionLimit()
test. Also new test cases are added:
* parameter_entity_run_in_DTD_huge_expansion makes sure that the
entity value is limited while it is being built, and not only after
the full expansion;
* entity_refs_in_parameter_entity verifies that general entity
references in a parameter entity are only expanded (and limited)
once the general entity that includes it is used in the document;
* parameter_entity_char_ref_in_DTD and
general_entity_in_parameter_entity_in_DTD cover the expansions of a
parameter entity included in the DTD.

(cherry picked from commit 039d8e1ef3e7e5b23924bcfa725bd80d6368e0ab)
Ivan Solovev <ivan.solovev@qt.io> no 2026-10-08
upstream_CVE-2026-105925_2.diff QXmlSimpleReader: add a property to control entity expansion limit
The limit was always set to 4096 characters, but was not enforced
consistently. Now, when the limit is applied more strictly, some of
the existing valid usecases can break, so we need a way to tune the
expansion limit.

Since we want to apply it retroactively to the existing branches, we
cannot add new public API for that, so let's try to use what we have.

QXml(Simple)Reader offers a property()/setProperty()/hasProperty()
API that so far was a no-op.
Add a new property that allows tuning of the entity expansion limit.
The only problem here is that the API uses void * for the input and
return values. To avoid handing out pointers to private members, the
limit value itself is passed through the void *, converted via
qintptr. This is explained in the new documentation.

[ChangeLog][Important Behavior Changes][QXmlSimpleReader] The entity
expansion limit of 4096 characters is now applied more strictly, which
can lead to some previously valid documents to be considered malformed.
Use setProperty() with a new property
"http://qt-project.org/xml/properties/entity-expansion-limit" to adjust
the limit.

(cherry picked from commit 3aee49e27e58b41af1050ec1b71bb71a9ad5ddfc)
Ivan Solovev <ivan.solovev@qt.io> no 2026-09-09

All known versions for source package 'qt6-5compat'

Links