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@
This commit is contained in:
naddy 2021-11-02 22:10:07 +00:00
parent cfeabe081a
commit 2e9999cb64
4 changed files with 54 additions and 4 deletions

View File

@ -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/

View File

@ -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) {

View File

@ -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 <stwo@users.sourceforge.net>
REVISION = 2
REVISION = 3
# BSD
PERMIT_PACKAGE = Yes

View File

@ -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) {