diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-03-23 16:31:04 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-03-24 10:02:42 +0000 |
commit | f2033b6623e13ad70f6648545571594a8cd848c7 (patch) | |
tree | 57fb07160ae8be9ce60e672d302440091d354868 | |
parent | c76fb95d45f0240ee00f831a88e8a52bf3faacbc (diff) |
ofz#57146 Integer-overflow
Change-Id: Ic5a86254b5d969c8242c124fa0515e4f1537114f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149460
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 71dbe5daa4e4..89c60fbe7baa 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -570,28 +570,33 @@ MetaTextAction::MetaTextAction( const Point& rPt, OUString aStr, mnLen ( nLen ) {} -static bool AllowY(tools::Long nY) +static bool AllowDim(tools::Long nDim) { static bool bFuzzing = utl::ConfigManager::IsFuzzing(); if (bFuzzing) { - if (nY > 0x20000000 || nY < -0x20000000) + if (nDim > 0x20000000 || nDim < -0x20000000) { - SAL_WARN("vcl", "skipping huge y: " << nY); + SAL_WARN("vcl", "skipping huge dimension: " << nDim); return false; } } return true; } +static bool AllowPoint(const Point& rPoint) +{ + return AllowDim(rPoint.X()) && AllowDim(rPoint.Y()); +} + static bool AllowRect(const tools::Rectangle& rRect) { - return AllowY(rRect.Top()) && AllowY(rRect.Bottom()); + return AllowDim(rRect.Top()) && AllowDim(rRect.Bottom()); } void MetaTextAction::Execute( OutputDevice* pOut ) { - if (!AllowY(pOut->LogicToPixel(maPt).Y())) + if (!AllowDim(pOut->LogicToPixel(maPt).Y())) return; pOut->DrawText( maPt, maStr, mnIndex, mnLen ); @@ -724,7 +729,7 @@ MetaStretchTextAction::MetaStretchTextAction( const Point& rPt, sal_uInt32 nWidt void MetaStretchTextAction::Execute( OutputDevice* pOut ) { - if (!AllowY(pOut->LogicToPixel(maPt).Y())) + if (!AllowDim(pOut->LogicToPixel(maPt).Y())) return; pOut->DrawStretchText( maPt, mnWidth, maStr, mnIndex, mnLen ); @@ -1483,7 +1488,7 @@ MetaMoveClipRegionAction::MetaMoveClipRegionAction( tools::Long nHorzMove, tools void MetaMoveClipRegionAction::Execute( OutputDevice* pOut ) { - if (!AllowY(pOut->LogicToPixel(Point(mnHorzMove, mnVertMove)).Y())) + if (!AllowPoint(pOut->LogicToPixel(Point(mnHorzMove, mnVertMove)))) return; pOut->MoveClipRegion( mnHorzMove, mnVertMove ); } |