external/libodfgen/UnpackedTarball_libodfgen.mk |    4 ++++
 external/libodfgen/ellipticalarc.patch          |   13 +++++++++++++
 2 files changed, 17 insertions(+)

New commits:
commit fa759359587808f5e74217e558ee3dd9143710f7
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Jul 29 16:45:50 2021 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Sun Aug 1 17:20:17 2021 +0200

    external/libodfgen: Avoid division by zero for empty elliptical arc
    
    ...as seen when running under UBSan `instdir/program/soffice --headless
    --convert-to epub` of caolan/libmspub_icu_global_buffer_overflow.sample 
from the
    crash-testing corpus.
    
    <https://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes> 
specifies:
    "If the endpoints (x1, y1) and (x2, y2) are identical, then this is 
equivalent
    to omitting the elliptical arc segment entirely."  (And 
getEllipticalArgBox's
    xmin, ymin, xmax, and ymax out parameters are pre-filled with suitable 
values at
    the call site in getPathBBox, so that we can return here without setting 
those
    out parameters.)
    
    Change-Id: I6b0b693354648f4015cec2395737fb9abe5ae956
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119680
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/external/libodfgen/UnpackedTarball_libodfgen.mk 
b/external/libodfgen/UnpackedTarball_libodfgen.mk
index d6c84e517970..89ff9eba353f 100644
--- a/external/libodfgen/UnpackedTarball_libodfgen.mk
+++ b/external/libodfgen/UnpackedTarball_libodfgen.mk
@@ -15,6 +15,10 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libodfgen,0))
 
 $(eval $(call gb_UnpackedTarball_update_autoconf_configs,libodfgen))
 
+$(eval $(call gb_UnpackedTarball_add_patches,libodfgen, \
+    external/libodfgen/ellipticalarc.patch \
+))
+
 ifeq ($(SYSTEM_REVENGE),)
 $(eval $(call gb_UnpackedTarball_add_patches,libodfgen, \
     external/libodfgen/rpath.patch \
diff --git a/external/libodfgen/ellipticalarc.patch 
b/external/libodfgen/ellipticalarc.patch
new file mode 100644
index 000000000000..27aaee77cb8a
--- /dev/null
+++ b/external/libodfgen/ellipticalarc.patch
@@ -0,0 +1,13 @@
+--- src/GraphicFunctions.cxx
++++ src/GraphicFunctions.cxx
+@@ -59,6 +59,10 @@
+                           double rx, double ry, double phi, bool largeArc, 
bool sweep, double x, double y,
+                           double &xmin, double &ymin, double &xmax, double 
&ymax)
+ {
++      if (x0 == x && y0 == y) {
++              return;
++      }
++
+       phi *= M_PI/180;
+       if (rx < 0.0)
+               rx *= -1.0;

Reply via email to