Kaydet (Commit) f69e2f73 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#5475 Integer-overflow

Change-Id: I11d706c544698d57b75231e33e3d49f1ac1d4d73
Reviewed-on: https://gerrit.libreoffice.org/48159Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 25d159dd
......@@ -497,7 +497,10 @@ namespace emfio
tools::Rectangle MtfTools::ImplMap( const tools::Rectangle& rRect )
{
return tools::Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) );
tools::Rectangle aRect;
aRect.SetPos(ImplMap(rRect.TopLeft()));
aRect.SaturatingSetSize(ImplMap(rRect.GetSize()));
return aRect;
}
void MtfTools::ImplMap( vcl::Font& rFont )
......
......@@ -430,6 +430,10 @@ public:
inline void expand(long nExpandBy);
inline void shrink(long nShrinkBy);
/**
* Sanitizing variants for handling data from the outside
*/
void SaturatingSetSize(const Size& rSize);
private:
long nLeft;
long nTop;
......
......@@ -3062,14 +3062,14 @@ void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
pValue->Value >>= nTmp;
Size aSize( aRect.GetSize() );
aSize.Width() = nTmp;
aRect.SetSize( aSize );
aRect.SaturatingSetSize(aSize);
}
else if (pValue->Name == "ViewAreaHeight" )
{
pValue->Value >>= nTmp;
Size aSize( aRect.GetSize() );
aSize.Height() = nTmp;
aRect.SetSize( aSize );
aRect.SaturatingSetSize(aSize);
}
pValue++;
}
......
......@@ -20,7 +20,7 @@
#include <sal/config.h>
#include <sstream>
#include <o3tl/safeint.hxx>
#include <tools/gen.hxx>
#include <tools/stream.hxx>
......@@ -68,6 +68,23 @@ void tools::Rectangle::SetSize( const Size& rSize )
nBottom = RECT_EMPTY;
}
void tools::Rectangle::SaturatingSetSize(const Size& rSize)
{
if (rSize.Width() < 0)
nRight = o3tl::saturating_add(nLeft, (rSize.Width() + 1));
else if ( rSize.Width() > 0 )
nRight = o3tl::saturating_add(nLeft, (rSize.Width() - 1));
else
nRight = RECT_EMPTY;
if ( rSize.Height() < 0 )
nBottom = o3tl::saturating_add(nTop, (rSize.Height() + 1));
else if ( rSize.Height() > 0 )
nBottom = o3tl::saturating_add(nTop, (rSize.Height() - 1));
else
nBottom = RECT_EMPTY;
}
tools::Rectangle& tools::Rectangle::Union( const tools::Rectangle& rRect )
{
if ( rRect.IsEmpty() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment