From 2e9999cb64efce2adca90cc3b6339fb4bfd9f168 Mon Sep 17 00:00:00 2001 From: naddy Date: Tue, 2 Nov 2021 22:10:07 +0000 Subject: [PATCH] lang/tcl/*: fix a data corruption bug triggered by LLVM 13's optimization Taken from upstream: "Fix unsafe buffer lifetime" https://core.tcl-lang.org/tcl/info/24b9181478 Upstream bug ticket found by sthen@ ok sthen@ --- lang/tcl/8.5/Makefile | 4 ++-- lang/tcl/8.5/patches/patch-generic_tclIO_c | 25 ++++++++++++++++++++++ lang/tcl/8.6/Makefile | 4 ++-- lang/tcl/8.6/patches/patch-generic_tclIO_c | 25 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 lang/tcl/8.5/patches/patch-generic_tclIO_c create mode 100644 lang/tcl/8.6/patches/patch-generic_tclIO_c diff --git a/lang/tcl/8.5/Makefile b/lang/tcl/8.5/Makefile index 88418dfd3a5..27df83f41f6 100644 --- a/lang/tcl/8.5/Makefile +++ b/lang/tcl/8.5/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.45 2019/07/12 20:47:23 sthen Exp $ +# $OpenBSD: Makefile,v 1.46 2021/11/02 22:10:07 naddy Exp $ COMMENT = Tool Command Language DISTNAME = tcl8.5.19 PKGNAME = tcl-8.5.19 PKGSTEM = tcl-8.5 -REVISION = 4 +REVISION = 5 SHARED_LIBS = tcl85 1.8 CATEGORIES = lang lang/tcl HOMEPAGE = http://www.tcl.tk/ diff --git a/lang/tcl/8.5/patches/patch-generic_tclIO_c b/lang/tcl/8.5/patches/patch-generic_tclIO_c new file mode 100644 index 00000000000..ac7cff97755 --- /dev/null +++ b/lang/tcl/8.5/patches/patch-generic_tclIO_c @@ -0,0 +1,25 @@ +$OpenBSD: patch-generic_tclIO_c,v 1.1 2021/11/02 22:10:08 naddy Exp $ + +Fix unsafe buffer lifetime +https://core.tcl-lang.org/tcl/info/24b9181478 + +Index: generic/tclIO.c +--- generic/tclIO.c.orig ++++ generic/tclIO.c +@@ -3765,6 +3765,7 @@ Write( + /* State info for channel */ + char *nextNewLine = NULL; + int endEncoding, saved = 0, total = 0, flushed = 0, needNlFlush = 0; ++ char safe[BUFFER_PADDING]; + + if (srcLen) { + WillWrite(chanPtr); +@@ -3783,7 +3784,7 @@ Write( + + while (srcLen + saved + endEncoding > 0) { + ChannelBuffer *bufPtr; +- char *dst, safe[BUFFER_PADDING]; ++ char *dst; + int result, srcRead, dstLen, dstWrote, srcLimit = srcLen; + + if (nextNewLine) { diff --git a/lang/tcl/8.6/Makefile b/lang/tcl/8.6/Makefile index c6ff40e02df..b6ea2f59d8a 100644 --- a/lang/tcl/8.6/Makefile +++ b/lang/tcl/8.6/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.23 2019/07/12 20:47:23 sthen Exp $ +# $OpenBSD: Makefile,v 1.24 2021/11/02 22:10:08 naddy Exp $ COMMENT = Tool Command Language @@ -10,7 +10,7 @@ SHARED_LIBS = tcl86 1.${P} CATEGORIES = lang lang/tcl HOMEPAGE = http://www.tcl.tk/ MAINTAINER = Stuart Cassoff -REVISION = 2 +REVISION = 3 # BSD PERMIT_PACKAGE = Yes diff --git a/lang/tcl/8.6/patches/patch-generic_tclIO_c b/lang/tcl/8.6/patches/patch-generic_tclIO_c new file mode 100644 index 00000000000..bef7d56d6f3 --- /dev/null +++ b/lang/tcl/8.6/patches/patch-generic_tclIO_c @@ -0,0 +1,25 @@ +$OpenBSD: patch-generic_tclIO_c,v 1.1 2021/11/02 22:10:08 naddy Exp $ + +Fix unsafe buffer lifetime +https://core.tcl-lang.org/tcl/info/24b9181478 + +Index: generic/tclIO.c +--- generic/tclIO.c.orig ++++ generic/tclIO.c +@@ -4242,6 +4242,7 @@ Write( + /* State info for channel */ + char *nextNewLine = NULL; + int endEncoding, saved = 0, total = 0, flushed = 0, needNlFlush = 0; ++ char safe[BUFFER_PADDING]; + + if (srcLen) { + WillWrite(chanPtr); +@@ -4260,7 +4261,7 @@ Write( + + while (srcLen + saved + endEncoding > 0) { + ChannelBuffer *bufPtr; +- char *dst, safe[BUFFER_PADDING]; ++ char *dst; + int result, srcRead, dstLen, dstWrote, srcLimit = srcLen; + + if (nextNewLine) {