summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2021-01-21 09:55:00 +0100
committerEirik Aavitsland <eirik.aavitsland@qt.io>2021-01-21 14:40:42 +0100
commit679750684087cad7a48921c4174a53cdf4855049 (patch)
tree3b02b6486ede24c28ac0dfaf3b292c7199584334
parentad84332f2bbe10601ba4c21fd6d4a446d16ed94c (diff)
Gracefully reject requests for absurd font sizes
Avoid overflows. Fixes: QTBUG-89899 Pick-to: 6.0 5.15 5.12 Change-Id: Ic1a83c1704fe20be3d032358dc91ee8e751f2281 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r--src/gui/text/qfontdatabase.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 6ac6a2089e..1968838691 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -2373,6 +2373,12 @@ QFontEngine *QFontDatabasePrivate::findFont(const QFontDef &request, int script)
return engine;
}
+ if (request.pixelSize > 0xffff) {
+ // Stop absurd requests reaching the engines; pixel size is assumed to fit ushort
+ qCDebug(lcFontMatch, "Rejecting request for pixel size %g2, returning box engine", double(request.pixelSize));
+ return new QFontEngineBox(32); // not request.pixelSize, to avoid overflow/DOS
+ }
+
QString family_name, foundry_name;
const QString requestFamily = request.families.at(0);
parseFontName(requestFamily, foundry_name, family_name);