summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-04-24 15:10:23 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-04-24 15:10:23 (GMT)
commit88661ac0e967d6c68f8ecdb76646b652214fe25b (patch)
treeacc60b1cd89061ad1e6245799aaefbaba21c2a08 /generic/tclEncoding.c
parent423df1f681b111dff8a5633b5aaa6e0049aaeddf (diff)
downloadtcl-88661ac0e967d6c68f8ecdb76646b652214fe25b.zip
tcl-88661ac0e967d6c68f8ecdb76646b652214fe25b.tar.gz
tcl-88661ac0e967d6c68f8ecdb76646b652214fe25b.tar.bz2
Add protections against overflow in Unicode values. Backported from 8.6. Also remove some out-of-date comments.
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index ac9f667..0824c4f 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2471,11 +2471,6 @@ UtfToUnicodeProc(
break;
}
src += TclUtfToUniChar(src, &ch);
- /*
- * Need to handle this in a way that won't cause misalignment
- * by casting dst to a Tcl_UniChar. [Bug 1122671]
- * XXX: This hard-codes the assumed size of Tcl_UniChar as 2.
- */
#if TCL_UTF_MAX > 3
if (ch & ~0xFFFF) {
ch = 0xFFFD;
@@ -2685,12 +2680,8 @@ TableFromUtfProc(
len = TclUtfToUniChar(src, &ch);
#if TCL_UTF_MAX > 3
- /*
- * This prevents a crash condition. More evaluation is required for
- * full support of int Tcl_UniChar. [Bug 1004065]
- */
-
- if (ch & 0xffff0000) {
+ /* Unicode chars > +U0FFFF cannot be represented in any table encoding */
+ if (ch & ~0xFFFF) {
word = 0;
} else
#endif