Wed Jun 8 19:00:13 2022 UTC ()
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.


(chuck)
diff -r1.2960 -r1.2961 pkgsrc/doc/CHANGES-2022
diff -r1.54 -r1.55 pkgsrc/fonts/t1lib/Makefile
diff -r1.26 -r1.27 pkgsrc/fonts/t1lib/distinfo
diff -r0 -r1.1 pkgsrc/fonts/t1lib/patches/patch-lib_type1_objects.h
diff -r0 -r1.1 pkgsrc/fonts/t1lib/patches/patch-lib_type1_regions.c

cvs diff -r1.2960 -r1.2961 pkgsrc/doc/CHANGES-2022 (expand / switch to unified diff)

--- pkgsrc/doc/CHANGES-2022 2022/06/08 17:57:17 1.2960
+++ pkgsrc/doc/CHANGES-2022 2022/06/08 19:00:13 1.2961
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1$NetBSD: CHANGES-2022,v 1.2960 2022/06/08 17:57:17 adam Exp $ 1$NetBSD: CHANGES-2022,v 1.2961 2022/06/08 19:00:13 chuck Exp $
2 2
3Changes to the packages collection and infrastructure in 2022: 3Changes to the packages collection and infrastructure in 2022:
4 4
5 Updated www/grafana to 8.3.3 [triaxx 2022-01-01] 5 Updated www/grafana to 8.3.3 [triaxx 2022-01-01]
6 Updated sysutils/py-ptyprocess to 0.7.0nb1 [martin 2022-01-01] 6 Updated sysutils/py-ptyprocess to 0.7.0nb1 [martin 2022-01-01]
7 Updated pkgtools/pkglint to 21.4.1 [rillig 2022-01-01] 7 Updated pkgtools/pkglint to 21.4.1 [rillig 2022-01-01]
8 Updated pkgtools/lintpkgsrc to 4.97 [rillig 2022-01-01] 8 Updated pkgtools/lintpkgsrc to 4.97 [rillig 2022-01-01]
9 Updated pkgtools/url2pkg to 21.4.0 [rillig 2022-01-01] 9 Updated pkgtools/url2pkg to 21.4.0 [rillig 2022-01-01]
10 Updated pkgtools/url2pkg to 21.4.1 [rillig 2022-01-01] 10 Updated pkgtools/url2pkg to 21.4.1 [rillig 2022-01-01]
11 Updated devel/mold to 1.0.1 [fcambus 2022-01-01] 11 Updated devel/mold to 1.0.1 [fcambus 2022-01-01]
12 Updated net/dbip-asn-lite to 2022.01 [fcambus 2022-01-01] 12 Updated net/dbip-asn-lite to 2022.01 [fcambus 2022-01-01]
13 Updated net/dbip-city-lite to 2022.01 [fcambus 2022-01-01] 13 Updated net/dbip-city-lite to 2022.01 [fcambus 2022-01-01]
14 Updated devel/py-backcall to 0.2.0nb1 [ryoon 2022-01-01] 14 Updated devel/py-backcall to 0.2.0nb1 [ryoon 2022-01-01]
@@ -4513,13 +4513,14 @@ Changes to the packages collection and i @@ -4513,13 +4513,14 @@ Changes to the packages collection and i
4513 Updated security/py-certbot-dns-rfc2136 to 1.28.0 [adam 2022-06-08] 4513 Updated security/py-certbot-dns-rfc2136 to 1.28.0 [adam 2022-06-08]
4514 Updated security/py-certbot-dns-route53 to 1.28.0 [adam 2022-06-08] 4514 Updated security/py-certbot-dns-route53 to 1.28.0 [adam 2022-06-08]
4515 Updated security/py-certbot-dns-sakuracloud to 1.28.0 [adam 2022-06-08] 4515 Updated security/py-certbot-dns-sakuracloud to 1.28.0 [adam 2022-06-08]
4516 Updated security/py-certbot-nginx to 1.28.0 [adam 2022-06-08] 4516 Updated security/py-certbot-nginx to 1.28.0 [adam 2022-06-08]
4517 Updated lang/nqp to 2022.06 [mef 2022-06-08] 4517 Updated lang/nqp to 2022.06 [mef 2022-06-08]
4518 Updated lang/rakudo to 2022.06 [mef 2022-06-08] 4518 Updated lang/rakudo to 2022.06 [mef 2022-06-08]
4519 Updated sysutils/auto-admin to 0.7.11 [bacon 2022-06-08] 4519 Updated sysutils/auto-admin to 0.7.11 [bacon 2022-06-08]
4520 Updated math/py-asteval to 0.9.27 [adam 2022-06-08] 4520 Updated math/py-asteval to 0.9.27 [adam 2022-06-08]
4521 Updated devel/py-typed-ast to 1.5.4 [adam 2022-06-08] 4521 Updated devel/py-typed-ast to 1.5.4 [adam 2022-06-08]
4522 Updated databases/py-redis to 4.3.3 [adam 2022-06-08] 4522 Updated databases/py-redis to 4.3.3 [adam 2022-06-08]
4523 Updated devel/py-filelock to 3.7.1 [adam 2022-06-08] 4523 Updated devel/py-filelock to 3.7.1 [adam 2022-06-08]
4524 Updated lang/python310 to 3.10.5 [adam 2022-06-08] 4524 Updated lang/python310 to 3.10.5 [adam 2022-06-08]
4525 Updated lang/py310-html-docs to 3.10.5 [adam 2022-06-08] 4525 Updated lang/py310-html-docs to 3.10.5 [adam 2022-06-08]
 4526 Updated fonts/t1lib to 5.1.2nb7 [chuck 2022-06-08]

cvs diff -r1.54 -r1.55 pkgsrc/fonts/t1lib/Makefile (expand / switch to unified diff)

--- pkgsrc/fonts/t1lib/Makefile 2019/11/02 22:24:43 1.54
+++ pkgsrc/fonts/t1lib/Makefile 2022/06/08 19:00:13 1.55
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1# $NetBSD: Makefile,v 1.54 2019/11/02 22:24:43 rillig Exp $ 1# $NetBSD: Makefile,v 1.55 2022/06/08 19:00:13 chuck Exp $
2 2
3DISTNAME= t1lib-5.1.2 3DISTNAME= t1lib-5.1.2
4PKGREVISION= 6 4PKGREVISION= 7
5CATEGORIES= fonts devel graphics 5CATEGORIES= fonts devel graphics
6MASTER_SITES= ${MASTER_SITE_SUNSITE:=libs/graphics/} 6MASTER_SITES= ${MASTER_SITE_SUNSITE:=libs/graphics/}
7 7
8MAINTAINER= pkgsrc-users@NetBSD.org 8MAINTAINER= pkgsrc-users@NetBSD.org
9COMMENT= Library for generating bitmaps from Adobe Type 1 fonts 9COMMENT= Library for generating bitmaps from Adobe Type 1 fonts
10 10
11MAKE_JOBS_SAFE= no 11MAKE_JOBS_SAFE= no
12 12
13USE_LIBTOOL= yes 13USE_LIBTOOL= yes
14USE_TOOLS+= gmake pax 14USE_TOOLS+= gmake pax
15GNU_CONFIGURE= yes 15GNU_CONFIGURE= yes
16 16
17BUILD_TARGET= without_doc 17BUILD_TARGET= without_doc

cvs diff -r1.26 -r1.27 pkgsrc/fonts/t1lib/distinfo (expand / switch to unified diff)

--- pkgsrc/fonts/t1lib/distinfo 2021/10/26 10:27:24 1.26
+++ pkgsrc/fonts/t1lib/distinfo 2022/06/08 19:00:13 1.27
@@ -1,14 +1,16 @@ @@ -1,14 +1,16 @@
1$NetBSD: distinfo,v 1.26 2021/10/26 10:27:24 nia Exp $ 1$NetBSD: distinfo,v 1.27 2022/06/08 19:00:13 chuck Exp $
2 2
3BLAKE2s (t1lib-5.1.2.tar.gz) = cab979b401fbc8c24ff30dc580c2b9bb03338681861ec263b5d897df8a686ff2 3BLAKE2s (t1lib-5.1.2.tar.gz) = cab979b401fbc8c24ff30dc580c2b9bb03338681861ec263b5d897df8a686ff2
4SHA512 (t1lib-5.1.2.tar.gz) = 9f424b19c6f35cc4f194ff7351a4c2352216462c7d1b1d9650ad3a05cf48c6e90c89ccbcda5ecc47a4169a39a850cf84a1fcbf88b3b15614860c27364b631ae3 4SHA512 (t1lib-5.1.2.tar.gz) = 9f424b19c6f35cc4f194ff7351a4c2352216462c7d1b1d9650ad3a05cf48c6e90c89ccbcda5ecc47a4169a39a850cf84a1fcbf88b3b15614860c27364b631ae3
5Size (t1lib-5.1.2.tar.gz) = 1872534 bytes 5Size (t1lib-5.1.2.tar.gz) = 1872534 bytes
6SHA1 (patch-aa) = 068c25f733c3037faa5051b527b1e1637d706a20 6SHA1 (patch-aa) = 068c25f733c3037faa5051b527b1e1637d706a20
7SHA1 (patch-ac) = 14201794e29a2eeba22a9144726ed3e00322aa1d 7SHA1 (patch-ac) = 14201794e29a2eeba22a9144726ed3e00322aa1d
8SHA1 (patch-ad) = 29c530f6d363de31777ad45823b55e72208c4ccb 8SHA1 (patch-ad) = 29c530f6d363de31777ad45823b55e72208c4ccb
9SHA1 (patch-af) = e89df0d94e0748e468c7c3d40ce2fc0ccdb0116c 9SHA1 (patch-af) = e89df0d94e0748e468c7c3d40ce2fc0ccdb0116c
10SHA1 (patch-ah) = 60ead43eeb6327cd3fd94755364633b6bf5d5d0d 10SHA1 (patch-ah) = 60ead43eeb6327cd3fd94755364633b6bf5d5d0d
11SHA1 (patch-ai) = 372740d7166ebb999a3c280d7de13df0901d9eb9 11SHA1 (patch-ai) = 372740d7166ebb999a3c280d7de13df0901d9eb9
12SHA1 (patch-aj) = bb915405fc5d64a74de09d7e4daba8822a08fbe1 12SHA1 (patch-aj) = bb915405fc5d64a74de09d7e4daba8822a08fbe1
13SHA1 (patch-ak) = abfbdb17c60b2068e95c5fe8e61ecfadbd85eea1 13SHA1 (patch-ak) = abfbdb17c60b2068e95c5fe8e61ecfadbd85eea1
14SHA1 (patch-al) = b0f0ab9398ce7e3f3bc3e8e54097fd4dbb566bc8 14SHA1 (patch-al) = b0f0ab9398ce7e3f3bc3e8e54097fd4dbb566bc8
 15SHA1 (patch-lib_type1_objects.h) = bcb1d938d8cd6db5b32e8db2c1a050d39244679a
 16SHA1 (patch-lib_type1_regions.c) = 75b12d30f73a649cbd0495a5cd735049a9bc4418

File Added: pkgsrc/fonts/t1lib/patches/patch-lib_type1_objects.h
$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*/

File Added: pkgsrc/fonts/t1lib/patches/patch-lib_type1_regions.c
$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);