summaryrefslogtreecommitdiff
path: root/emfio
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 18:34:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-16 09:11:41 +0200
commit059f07f9f33460c809a93e0fda1165f5c6f6d805 (patch)
tree09bbd8b4daab16e8752b3bcf6e2d3b6602bb801a /emfio
parent2670e980c7dbadbdc20ff23d57ad892951edc254 (diff)
fixes for code creating reversed Rectangles
ie. where left > right or top > bottom These are all places where the code is self-evidently doing the wrong thing. Found by adding asserts to tools::Rectangle. In theory, this is legit, and code that wants a proper Rectangle is supposed to be first call Justify on a Rectangle, but lots of places don't do that, and that seems very dodgy to me. So lets work towards Rectangles always being in a valid state. Change-Id: I03296a624bd9b5b193e6aa8778addfb09708cdc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92310 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'emfio')
-rw-r--r--emfio/source/reader/emfreader.cxx6
-rw-r--r--emfio/source/reader/wmfreader.cxx6
2 files changed, 12 insertions, 0 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 35a5f020d0fa..252015bab2e6 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -2088,6 +2088,12 @@ namespace emfio
mpInputStream->ReadInt32(nBottom);
SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom);
+ if (nLeft > nRight || nTop > nBottom)
+ {
+ SAL_WARN("emfio", "broken rectangle");
+ mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return tools::Rectangle();
+ }
return tools::Rectangle(nLeft, nTop, nRight, nBottom);
}
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx
index 1d67f5c52e98..3f8af75bbd50 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -165,6 +165,12 @@ namespace emfio
aTL = ReadYX();
aBR.AdjustX( -1 );
aBR.AdjustY( -1 );
+ if (aTL.X() > aBR.X() || aTL.Y() > aBR.Y())
+ {
+ SAL_WARN("vcl.wmf", "broken rectangle");
+ mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ return tools::Rectangle();
+ }
return tools::Rectangle( aTL, aBR );
}