[Libreoffice-commits] core.git: 2 commits - external/libcdr

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed May 29 19:43:35 UTC 2019


 external/libcdr/0001-Add-missing-include.patch.1 |   33 +++++++++++
 external/libcdr/ExternalProject_libcdr.mk        |    2 
 external/libcdr/UnpackedTarball_libcdr.mk        |    6 ++
 external/libcdr/ubsan.patch                      |   64 +++++++++++++++++++++++
 4 files changed, 104 insertions(+), 1 deletion(-)

New commits:
commit 4c707b78a705d6cc74061433cd01175283fabb2e
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed May 29 18:31:57 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed May 29 21:42:24 2019 +0200

    external/libcdr: Avoid UB converting from double to int via unsigned
    
    Opening cdr/fdo53278-4.cdr as obtained by
    bin/get-bugzilla-attachments-by-mimetype (i.e., the attachment at
    <https://bugs.documentfoundation.org/show_bug.cgi?id=53278#c14>) under
    -fsanitize=undefined causes
    
    > CDRPath.cpp:821:34: runtime error: -173.908 is outside the range of representable values of type 'unsigned int'
    >  #0 in libcdr::CDRPath::writeOut(librevenge::RVNGString&, librevenge::RVNGString&, double&) const at workdir/UnpackedTarball/libcdr/src/lib/CDRPath.cpp:821:34 (instdir/program/../program/libwpftdrawlo.so +0x2380015)
    >  #1 in libcdr::CDRContentCollector::_lineProperties(librevenge::RVNGPropertyList&) at workdir/UnpackedTarball/libcdr/src/lib/CDRContentCollector.cpp:1118:17 (instdir/program/../program/libwpftdrawlo.so +0x2090b54)
    >  #2 in libcdr::CDRContentCollector::_flushCurrentPath() at workdir/UnpackedTarball/libcdr/src/lib/CDRContentCollector.cpp:240:5 (instdir/program/../program/libwpftdrawlo.so +0x2070a9e)
    >  #3 in libcdr::CDRContentCollector::collectLevel(unsigned int) at workdir/UnpackedTarball/libcdr/src/lib/CDRContentCollector.cpp:563:5 (instdir/program/../program/libwpftdrawlo.so +0x209243d)
    >  #4 in libcdr::CDRParser::parseRecord(librevenge::RVNGInputStream*, std::vector<unsigned int, std::allocator<unsigned int> > const&, unsigned int) at workdir/UnpackedTarball/libcdr/src/lib/CDRParser.cpp:514:18 (instdir/program/../program/libwpftdrawlo.so +0x213bdff)
    >  #5 in libcdr::CDRParser::parseRecords(librevenge::RVNGInputStream*, std::vector<unsigned int, std::allocator<unsigned int> > const&, unsigned int) at workdir/UnpackedTarball/libcdr/src/lib/CDRParser.cpp:500:10 (instdir/program/../program/libwpftdrawlo.so +0x213b93f)
    [...]
    
    Change-Id: Ie73965851102689ebb7895d61edb3d32ff47c60c
    Reviewed-on: https://gerrit.libreoffice.org/73181
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/external/libcdr/UnpackedTarball_libcdr.mk b/external/libcdr/UnpackedTarball_libcdr.mk
index 0c61c5962385..d53ea59e2bf6 100644
--- a/external/libcdr/UnpackedTarball_libcdr.mk
+++ b/external/libcdr/UnpackedTarball_libcdr.mk
@@ -16,10 +16,13 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libcdr,0))
 $(eval $(call gb_UnpackedTarball_update_autoconf_configs,libcdr))
 
 # * external/libcdr/0001-Add-missing-include.patch.1 is from upstream master (see content for
-#   details):
+#   details);
+# * external/libcdr/ubsan.patch is upstream at <https://gerrit.libreoffice.org/#/c/73182/> "Avoid UB
+#   converting from double to int via unsigned":
 $(eval $(call gb_UnpackedTarball_add_patches,libcdr, \
     external/libcdr/libcdr-visibility-win.patch \
     external/libcdr/0001-Add-missing-include.patch.1 \
+    external/libcdr/ubsan.patch \
 ))
 
 ifeq ($(NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY),TRUE)
diff --git a/external/libcdr/ubsan.patch b/external/libcdr/ubsan.patch
new file mode 100644
index 000000000000..316c47a45ab9
--- /dev/null
+++ b/external/libcdr/ubsan.patch
@@ -0,0 +1,64 @@
+--- src/lib/CDRPath.cpp
++++ src/lib/CDRPath.cpp
+@@ -796,7 +796,7 @@ void CDRPath::writeOut(librevenge::RVNGString &path, librevenge::RVNGString &vie
+ 
+ 
+   width = qy - py;
+-  viewBox.sprintf("%i %i %i %i", 0, 0, (unsigned)(2540*(qx - px)), (unsigned)(2540*(qy - py)));
++  viewBox.sprintf("%i %i %i %i", 0, 0, (int)(2540*(qx - px)), (int)(2540*(qy - py)));
+ 
+   for (unsigned i = 0; i < vec.count(); ++i)
+   {
+@@ -804,38 +804,38 @@ void CDRPath::writeOut(librevenge::RVNGString &path, librevenge::RVNGString &vie
+     if (vec[i]["librevenge:path-action"]->getStr() == "M")
+     {
+       // 2540 is 2.54*1000, 2.54 in = 1 inch
+-      sElement.sprintf("M%i %i", (unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
+-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
++      sElement.sprintf("M%i %i", (int)((vec[i]["svg:x"]->getDouble()-px)*2540),
++                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
+       path.append(sElement);
+     }
+     else if (vec[i]["librevenge:path-action"]->getStr() == "L")
+     {
+-      sElement.sprintf("L%i %i", (unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
+-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
++      sElement.sprintf("L%i %i", (int)((vec[i]["svg:x"]->getDouble()-px)*2540),
++                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
+       path.append(sElement);
+     }
+     else if (vec[i]["librevenge:path-action"]->getStr() == "C")
+     {
+-      sElement.sprintf("C%i %i %i %i %i %i", (unsigned)((vec[i]["svg:x1"]->getDouble()-px)*2540),
+-                       (unsigned)((vec[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((vec[i]["svg:x2"]->getDouble()-px)*2540),
+-                       (unsigned)((vec[i]["svg:y2"]->getDouble()-py)*2540), (unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
+-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
++      sElement.sprintf("C%i %i %i %i %i %i", (int)((vec[i]["svg:x1"]->getDouble()-px)*2540),
++                       (int)((vec[i]["svg:y1"]->getDouble()-py)*2540), (int)((vec[i]["svg:x2"]->getDouble()-px)*2540),
++                       (int)((vec[i]["svg:y2"]->getDouble()-py)*2540), (int)((vec[i]["svg:x"]->getDouble()-px)*2540),
++                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
+       path.append(sElement);
+     }
+     else if (vec[i]["librevenge:path-action"]->getStr() == "Q")
+     {
+-      sElement.sprintf("Q%i %i %i %i", (unsigned)((vec[i]["svg:x1"]->getDouble()-px)*2540),
+-                       (unsigned)((vec[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540),
+-                       (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
++      sElement.sprintf("Q%i %i %i %i", (int)((vec[i]["svg:x1"]->getDouble()-px)*2540),
++                       (int)((vec[i]["svg:y1"]->getDouble()-py)*2540), (int)((vec[i]["svg:x"]->getDouble()-px)*2540),
++                       (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
+       path.append(sElement);
+     }
+     else if (vec[i]["librevenge:path-action"]->getStr() == "A")
+     {
+-      sElement.sprintf("A%i %i %i %i %i %i %i", (unsigned)((vec[i]["svg:rx"]->getDouble())*2540),
+-                       (unsigned)((vec[i]["svg:ry"]->getDouble())*2540), (vec[i]["librevenge:rotate"] ? vec[i]["librevenge:rotate"]->getInt() : 0),
++      sElement.sprintf("A%i %i %i %i %i %i %i", (int)((vec[i]["svg:rx"]->getDouble())*2540),
++                       (int)((vec[i]["svg:ry"]->getDouble())*2540), (vec[i]["librevenge:rotate"] ? vec[i]["librevenge:rotate"]->getInt() : 0),
+                        (vec[i]["librevenge:large-arc"] ? vec[i]["librevenge:large-arc"]->getInt() : 1),
+                        (vec[i]["librevenge:sweep"] ? vec[i]["librevenge:sweep"]->getInt() : 1),
+-                       (unsigned)((vec[i]["svg:x"]->getDouble()-px)*2540), (unsigned)((vec[i]["svg:y"]->getDouble()-py)*2540));
++                       (int)((vec[i]["svg:x"]->getDouble()-px)*2540), (int)((vec[i]["svg:y"]->getDouble()-py)*2540));
+       path.append(sElement);
+     }
+     else if (vec[i]["librevenge:path-action"]->getStr() == "Z")
commit c7ece07d2e1b478bf25a976618e9bc5e5bc1a144
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed May 29 17:57:57 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed May 29 21:41:48 2019 +0200

    Pass --enable-debug into external/libcdr
    
    (but which requires a little upstream master patch)
    
    Change-Id: I4bea938c402b03d8b05b6e70694ecc0184544b81
    Reviewed-on: https://gerrit.libreoffice.org/73179
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/external/libcdr/0001-Add-missing-include.patch.1 b/external/libcdr/0001-Add-missing-include.patch.1
new file mode 100644
index 000000000000..93f2b6ccc6fc
--- /dev/null
+++ b/external/libcdr/0001-Add-missing-include.patch.1
@@ -0,0 +1,33 @@
+From 00c4b331df8157dff7c251323d00ec2d63691dfb Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.com>
+Date: Mon, 28 Jan 2019 09:04:56 +0100
+Subject: [PATCH] Add missing include
+
+CMXParser.cpp:42:43: error: expected ')'
+    CDR_DEBUG_MSG(("invalid tag length %" PRIu16 "\n", tagLength));
+                                          ^
+CMXParser.cpp:42:19: note: to match this '('
+    CDR_DEBUG_MSG(("invalid tag length %" PRIu16 "\n", tagLength));
+                  ^
+1 error generated.
+
+Change-Id: I9575a96327a62dc6c44950d35a8740242e1a4433
+---
+ src/lib/CMXParser.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp
+index 78cc417..02852c9 100644
+--- a/src/lib/CMXParser.cpp
++++ b/src/lib/CMXParser.cpp
+@@ -14,6 +14,7 @@
+ #include <math.h>
+ #include <stdlib.h>
+ #include <utility>
++#include <cinttypes>
+ 
+ #include "libcdr_utils.h"
+ #include "CDRPath.h"
+-- 
+2.21.0
+
diff --git a/external/libcdr/ExternalProject_libcdr.mk b/external/libcdr/ExternalProject_libcdr.mk
index 5e895a5fc1e3..503307cf3488 100644
--- a/external/libcdr/ExternalProject_libcdr.mk
+++ b/external/libcdr/ExternalProject_libcdr.mk
@@ -32,7 +32,7 @@ $(call gb_ExternalProject_get_state_target,libcdr,build) :
 			--disable-shared \
 			--without-docs \
 			--disable-tools \
-			--disable-debug \
+			$(if $(ENABLE_DEBUG),--enable-debug,--disable-debug) \
 			--disable-werror \
 			--disable-weffc \
 			$(if $(gb_FULLDEPS),,--disable-dependency-tracking) \
diff --git a/external/libcdr/UnpackedTarball_libcdr.mk b/external/libcdr/UnpackedTarball_libcdr.mk
index 7433d2bb4e67..0c61c5962385 100644
--- a/external/libcdr/UnpackedTarball_libcdr.mk
+++ b/external/libcdr/UnpackedTarball_libcdr.mk
@@ -15,8 +15,11 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libcdr,0))
 
 $(eval $(call gb_UnpackedTarball_update_autoconf_configs,libcdr))
 
+# * external/libcdr/0001-Add-missing-include.patch.1 is from upstream master (see content for
+#   details):
 $(eval $(call gb_UnpackedTarball_add_patches,libcdr, \
     external/libcdr/libcdr-visibility-win.patch \
+    external/libcdr/0001-Add-missing-include.patch.1 \
 ))
 
 ifeq ($(NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY),TRUE)


More information about the Libreoffice-commits mailing list