pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc work around clang compiler issue and malloc overflow i...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b9879a80a81d
branches:  trunk
changeset: 380569:b9879a80a81d
user:      chuck <chuck%pkgsrc.org@localhost>
date:      Wed Jun 08 19:00:13 2022 +0000

description:
work around clang compiler issue and malloc overflow in t1lib

there are two bugs in fonts/t1lib that cause math/grace to crash on OSX:

[1] compiler bug in some versions of clang when compiling with "-O2" ...
    this appears to have been fixed somewhere between clang-11 and clang-12.
    it works ok with "-O1" and it doesn't impact my NetBSD system (which
    has gcc instead of clang).   resolve by using memcpy() in LONGCOPY()
    macro rather than using custom code that triggers the clang issue.
    see: https://mail-index.netbsd.org/tech-pkg/2022/06/08/msg026367.html

[2] one case of t1lib trying to be clever and instead writing past end of
     malloc'd buffer (which the OSX malloc did not like at all;  the netbsd
     malloc did not get messed up by this).   the address sanitizer helped
     pinpoint this.

diffstat:

 doc/CHANGES-2022                              |   3 ++-
 fonts/t1lib/Makefile                          |   4 ++--
 fonts/t1lib/distinfo                          |   4 +++-
 fonts/t1lib/patches/patch-lib_type1_objects.h |  25 +++++++++++++++++++++++++
 fonts/t1lib/patches/patch-lib_type1_regions.c |  18 ++++++++++++++++++
 5 files changed, 50 insertions(+), 4 deletions(-)

diffs (93 lines):

diff -r 7aecd2554e2f -r b9879a80a81d doc/CHANGES-2022
--- a/doc/CHANGES-2022  Wed Jun 08 17:57:17 2022 +0000
+++ b/doc/CHANGES-2022  Wed Jun 08 19:00:13 2022 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES-2022,v 1.2960 2022/06/08 17:57:17 adam Exp $
+$NetBSD: CHANGES-2022,v 1.2961 2022/06/08 19:00:13 chuck Exp $
 
 Changes to the packages collection and infrastructure in 2022:
 
@@ -4523,3 +4523,4 @@
        Updated devel/py-filelock to 3.7.1 [adam 2022-06-08]
        Updated lang/python310 to 3.10.5 [adam 2022-06-08]
        Updated lang/py310-html-docs to 3.10.5 [adam 2022-06-08]
+       Updated fonts/t1lib to 5.1.2nb7 [chuck 2022-06-08]
diff -r 7aecd2554e2f -r b9879a80a81d fonts/t1lib/Makefile
--- a/fonts/t1lib/Makefile      Wed Jun 08 17:57:17 2022 +0000
+++ b/fonts/t1lib/Makefile      Wed Jun 08 19:00:13 2022 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.54 2019/11/02 22:24:43 rillig Exp $
+# $NetBSD: Makefile,v 1.55 2022/06/08 19:00:13 chuck Exp $
 
 DISTNAME=      t1lib-5.1.2
-PKGREVISION=   6
+PKGREVISION=   7
 CATEGORIES=    fonts devel graphics
 MASTER_SITES=  ${MASTER_SITE_SUNSITE:=libs/graphics/}
 
diff -r 7aecd2554e2f -r b9879a80a81d fonts/t1lib/distinfo
--- a/fonts/t1lib/distinfo      Wed Jun 08 17:57:17 2022 +0000
+++ b/fonts/t1lib/distinfo      Wed Jun 08 19:00:13 2022 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.26 2021/10/26 10:27:24 nia Exp $
+$NetBSD: distinfo,v 1.27 2022/06/08 19:00:13 chuck Exp $
 
 BLAKE2s (t1lib-5.1.2.tar.gz) = cab979b401fbc8c24ff30dc580c2b9bb03338681861ec263b5d897df8a686ff2
 SHA512 (t1lib-5.1.2.tar.gz) = 9f424b19c6f35cc4f194ff7351a4c2352216462c7d1b1d9650ad3a05cf48c6e90c89ccbcda5ecc47a4169a39a850cf84a1fcbf88b3b15614860c27364b631ae3
@@ -12,3 +12,5 @@
 SHA1 (patch-aj) = bb915405fc5d64a74de09d7e4daba8822a08fbe1
 SHA1 (patch-ak) = abfbdb17c60b2068e95c5fe8e61ecfadbd85eea1
 SHA1 (patch-al) = b0f0ab9398ce7e3f3bc3e8e54097fd4dbb566bc8
+SHA1 (patch-lib_type1_objects.h) = bcb1d938d8cd6db5b32e8db2c1a050d39244679a
+SHA1 (patch-lib_type1_regions.c) = 75b12d30f73a649cbd0495a5cd735049a9bc4418
diff -r 7aecd2554e2f -r b9879a80a81d fonts/t1lib/patches/patch-lib_type1_objects.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/fonts/t1lib/patches/patch-lib_type1_objects.h     Wed Jun 08 19:00:13 2022 +0000
@@ -0,0 +1,25 @@
+$NetBSD: patch-lib_type1_objects.h,v 1.1 2022/06/08 19:00:13 chuck Exp $
+
+Point LONGLONG macro at memcpy() rather than using t1lib custom code.
+The t1lib version causes some versions of clang to produce incorrect
+code when compiled with -O2.  Newer versions of clang (>= clang-12)
+have fixed the issue.  see note in:
+    https://mail-index.netbsd.org/tech-pkg/2022/06/08/msg026367.html
+
+--- lib/type1/objects.h.orig   2022-06-08 13:28:14.000000000 -0400
++++ lib/type1/objects.h        2022-06-08 13:28:29.000000000 -0400
+@@ -152,10 +152,14 @@
+ /*END SHARED*/
+ /*SHARED*/
+  
++#if 0
+ #define  LONGCOPY(dest,source,bytes) { \
+     register LONG *p1 = (LONG *)dest;  register LONG *p2 = (LONG *)source; \
+     register int count = (bytes) / sizeof(LONG); \
+     while (--count >= 0) *p1++ = *p2++; }
++#else
++#define  LONGCOPY(dest,source,bytes) memcpy(dest,source,bytes)
++#endif
+  
+  
+ /*END SHARED*/
diff -r 7aecd2554e2f -r b9879a80a81d fonts/t1lib/patches/patch-lib_type1_regions.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/fonts/t1lib/patches/patch-lib_type1_regions.c     Wed Jun 08 19:00:13 2022 +0000
@@ -0,0 +1,18 @@
+$NetBSD: patch-lib_type1_regions.c,v 1.1 2022/06/08 19:00:13 chuck Exp $
+
+Fixed incorrect calculation of ceiling that results in t1lib LONGCOPY
+writing past the end of a malloc buffer.   Corrects crash on OSX
+and resolves complaints from the address sanitizer.
+
+--- lib/type1/regions.c.orig   2022-06-08 13:28:23.000000000 -0400
++++ lib/type1/regions.c        2022-06-08 13:28:31.000000000 -0400
+@@ -340,7 +340,8 @@
+ longs.  The destination must be able to hold these extra bytes because
+ Allocate() makes everything it allocates be in multiples of longs.
+ */
+-       LONGCOPY(&r[1], xvalues, (ymax - iy) * sizeof(pel) + sizeof(LONG) - 1);
++       LONGCOPY(&r[1], xvalues,
++         ((ymax - iy) * sizeof(pel) + sizeof(LONG) - 1) & ~(sizeof(LONG) - 1));
+  
+        IfTrace1((RegionDebug),"result=%p\n", r);
+        return(r);



Home | Main Index | Thread Index | Old Index