Linguist: Fix out-of-bounds read when reading a QM file


loadQM() locates each message record through an offset read from the
file and then reads per-field lengths from within the message block,
advancing a pointer by those lengths. The length check done while
scanning the top-level blocks does not cover these inner offsets and
lengths, so a corrupted QM file with an out-of-range record offset or an
oversized field length makes the reader access memory past the end of
the file buffer. This crashes lconvert and Qt Linguist, or copies
adjacent process memory into the produced translation.

Track the size of the message block and reject record offsets outside
it, and check the number of available bytes before every tag, length
and payload read, failing with a format error otherwise.

Fixes: QTBUG-148061
Change-Id: Ifd9f9b27183bf0aee040577afd530a2b7f622d93
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
commitc2e963bc115044fca1d647de91e800be7d71dc0c
parent77450bf7c0a25be4817282d6f62a0f09be25b8d4
authorMasoud Jami <masoud.jami@qt.io>
committerMasoud Jami <masoud.jami@qt.io>
commit timeTue, 14 Jul 2026 08:27:09 +0000