summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-21 16:15:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-03-22 16:02:12 +0100
commitfcf785b82b92ecfff942577dafc27b1369c5e19c (patch)
tree88cad0c3933d26c5df22c5711de8fffbd98071f3 /vcl
parent4b3b9e7af77e7c0501fe4c87a3dfbe3b314cc085 (diff)
ofz#45583 Integer-overflow on drawEPS
Change-Id: I6a8add3e2ba695d2012916280a7f976b7b11934d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131908 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz45583-1.svmbin0 -> 2238 bytes
-rw-r--r--vcl/source/gdi/TypeSerializer.cxx13
-rw-r--r--vcl/source/gdi/gdimtf.cxx11
3 files changed, 19 insertions, 5 deletions
diff --git a/vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz45583-1.svm b/vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz45583-1.svm
new file mode 100644
index 000000000000..d730a1bccf4f
--- /dev/null
+++ b/vcl/qa/cppunit/graphicfilter/data/svm/pass/ofz45583-1.svm
Binary files differ
diff --git a/vcl/source/gdi/TypeSerializer.cxx b/vcl/source/gdi/TypeSerializer.cxx
index 829bc0503e1d..dfaf300c7801 100644
--- a/vcl/source/gdi/TypeSerializer.cxx
+++ b/vcl/source/gdi/TypeSerializer.cxx
@@ -425,10 +425,8 @@ void TypeSerializer::writeGraphic(const Graphic& rGraphic)
}
}
-static bool UselessScaleForMapMode(const Fraction& rScale)
+bool TooLargeScaleForMapMode(const Fraction& rScale)
{
- if (!rScale.IsValid())
- return true;
// ImplLogicToPixel will multiply its values by this numerator * dpi and then double that
// result before dividing
constexpr sal_Int32 nTypicalDPI = 96;
@@ -436,6 +434,15 @@ static bool UselessScaleForMapMode(const Fraction& rScale)
return true;
if (rScale.GetNumerator() < std::numeric_limits<sal_Int32>::min() / nTypicalDPI / 2)
return true;
+ return false;
+}
+
+static bool UselessScaleForMapMode(const Fraction& rScale)
+{
+ if (!rScale.IsValid())
+ return true;
+ if (TooLargeScaleForMapMode(rScale))
+ return true;
if (static_cast<double>(rScale) < 0.0)
return true;
return false;
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index a747e55f5685..dd682420c1eb 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -478,8 +478,15 @@ void GDIMetaFile::Play(OutputDevice& rOut, const Point& rPos,
Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() );
Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() );
- aScaleX *= aDrawMap.GetScaleX(); aDrawMap.SetScaleX( aScaleX );
- aScaleY *= aDrawMap.GetScaleY(); aDrawMap.SetScaleY( aScaleY );
+ aScaleX *= aDrawMap.GetScaleX();
+ if (TooLargeScaleForMapMode(aScaleX))
+ aScaleX.ReduceInaccurate(10);
+ aScaleY *= aDrawMap.GetScaleY();
+ if (TooLargeScaleForMapMode(aScaleY))
+ aScaleY.ReduceInaccurate(10);
+
+ aDrawMap.SetScaleX(aScaleX);
+ aDrawMap.SetScaleY(aScaleY);
// #i47260# Convert logical output position to offset within
// the metafile's mapmode. Therefore, disable pixel offset on