Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Possible regex ranges integer overflow

Closed / Invalid67fcef9acaf767003180ee05b8a35ef8ea6ae049Created 11 years agoUpdated 42 days ago
Descriptionplain2016-02-16 09:56:13
Just opening the case in tcl upstream, to be aware of the problem:

https://github.com/SWI-Prolog/packages-xpce/issues/2

The chr type is 16bit, hence the maximum range size is limited to 2^16, which is not sufficient to trigger the overflow. Note that TCL can be built with 32bit chr type depending on the value of TCL_UTF_MAX macro. The default value is 3, which implies the use of 16bit chr. Other valid value is 6, but that is considered experimental upstream and not recommended.
serhiy.storchakawiki2026-10-11 11:04:57

Not reproducible in 8.6, 9.0 or 9.1. Regexp escapes are capped at U+10FFFF (lexdigits() in regc_lex.c), CHR_MAX is 0x10FFFF in 9.x, and range() uses int, so neither the loop nor the allocation size can overflow. In 8.6, chr is 16-bit by default, and the escape cap also applies with TCL_UTF_MAX > 4. The full case-insensitive range [\U00000000-\U0010ffff] compiles in milliseconds.

serhiy.storchaka Closed ticket [67fcef9aca]. [History diff]2026-10-11 11:04:57
serhiy.storchaka Ticket [67fcef9aca]: 3 changes [History diff]2026-10-22 17:19:24
Log in (anonymous is fine) to add a comment.