Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[expr] can bypass [interp limit]

Open2006342fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-06-30 03:37:54
The arbitrary-precision integers support in [expr] can cause it to run for quite some time; however, it cannot currently be interrupted by [interp limit].  For safe interpreters, this could lead to a potential denial-of-service.

Example:

% info patchlevel
8.5.2
% set i [interp create]
interp0
% interp limit $i time -seconds [expr {[clock seconds] + 10}]
% interp limit $i time
-command {} -granularity 10 -milliseconds 0 -seconds 1214796621
% interp eval $i {expr 2**9999999}

The above script does not return even after the limit has elapsed.
mistachkinplain2008-06-30 10:39:16
Logged In: YES 
user_id=113501
Originator: YES


This limitation applies to [interp cancel] as well.
dkfplain2008-07-13 15:41:20
Logged In: YES 
user_id=79902
Originator: NO

The only way to deal with this nicely is to add limit checks to the bignum engine. I don't know that we want to do that...
dkfplain2008-07-13 18:19:05
Logged In: YES 
user_id=79902
Originator: NO

BTW, on a fast modern machine where we're not running into swapping problems, that computation will take on the order of 10 minutes to perform, and that's excluding the cost of generating a string representation of it (which would probably be at least as long again).
Log in (anonymous is fine) to add a comment.