summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-02-26 20:04:15 +0000
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-03-04 15:02:50 +0100
commit5082db125f914fac48a91712d94275ebeb1db4f3 (patch)
tree8e5337674fbbeb2493e2944278866b42fb82b13e
parentddd16156c040a97619929c31a310308688211b95 (diff)
ofz#44991 keep within legal ArrowShape range
Change-Id: I6bf70f27a66ba9b355a3f7ae0c68a696a7284871 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130562 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 7171ec3e400505fbeead152718eebd5cc6c624d7)
-rw-r--r--hwpfilter/source/hwpreader.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 5dccd3b7b7b2..fa337533b3b3 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -24,6 +24,7 @@
#include <math.h>
#include <osl/diagnose.h>
+#include <o3tl/safeint.hxx>
#include <tools/stream.hxx>
#include "fontmap.hxx"
@@ -460,7 +461,9 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC || hdo->type == HWPDO_FREEFORM ||
hdo->type == HWPDO_ADVANCED_ARC )
{
- if( prop->line_tstyle && !ArrowShape[prop->line_tstyle].bMade )
+ if( prop->line_tstyle > 0 &&
+ o3tl::make_unsigned(prop->line_tstyle) < std::size(ArrowShape) &&
+ !ArrowShape[prop->line_tstyle].bMade )
{
ArrowShape[prop->line_tstyle].bMade = true;
padd("draw:name", sXML_CDATA,
@@ -484,7 +487,9 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
mxList->clear();
rendEl("draw:marker");
}
- if( prop->line_hstyle && !ArrowShape[prop->line_hstyle].bMade)
+ if (prop->line_hstyle > 0 &&
+ o3tl::make_unsigned(prop->line_hstyle) < std::size(ArrowShape) &&
+ !ArrowShape[prop->line_hstyle].bMade)
{
ArrowShape[prop->line_hstyle].bMade = true;
padd("draw:name", sXML_CDATA,
@@ -2041,7 +2046,8 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle)
hdo->type == HWPDO_FREEFORM || hdo->type == HWPDO_ADVANCED_ARC )
{
- if( hdo->property.line_tstyle > 0 )
+ if( hdo->property.line_tstyle > 0 &&
+ o3tl::make_unsigned(hdo->property.line_tstyle) < std::size(ArrowShape) )
{
padd("draw:marker-start", sXML_CDATA,
ascii(ArrowShape[hdo->property.line_tstyle].name) );
@@ -2062,7 +2068,8 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle)
Double2Str( WTMM(hdo->property.line_width * 7)) + "mm");
}
- if( hdo->property.line_hstyle > 0 )
+ if( hdo->property.line_hstyle > 0 &&
+ o3tl::make_unsigned(hdo->property.line_hstyle) < std::size(ArrowShape) )
{
padd("draw:marker-end", sXML_CDATA,
ascii(ArrowShape[hdo->property.line_hstyle].name) );