hwpfilter/source/hwpreader.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
New commits: commit 0416c8e9a99c86c941236ce195845d6aa3c36910 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sat Feb 26 20:04:15 2022 +0000 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Wed Mar 2 09:36:48 2022 +0100 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.st...@allotropia.de> (cherry picked from commit 7171ec3e400505fbeead152718eebd5cc6c624d7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130808 Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> 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) );