Skip to content
Tcl Source Code View Ticket
Login

View Ticket

scan %s truncates strings at UINT_MAX

Closed / Fixedd4ede611a7a7c802d7c5b42c93dded85d41b7184Created 4 years agoUpdated 4 years ago
Descriptionmarkdown2023-04-09 23:50:16
% set s [string repeat x 0x100000000] ; string length $s
4294967296
% string length [scan $s %s]
4294967295
Referenced by3
apnadkarni Ticket [d4ede611a7]: 3 changes [History diff]2023-04-12 16:17:40
apnadkarnimarkdown2023-04-22 18:00:34

Other issues with scan.

Large positional qualifiers.

scan abc {%2147483648$s} -> memory access violation

Large width specifiers are truncated.

% set s [testbigdata string 0x10000000a]; string length $s
4294967306
% scan $s %4294967300s%s x y
2
% string length $y
11
% string length $x
4294967295
apnadkarniplain2023-04-24 14:52:43
Fixed in [acaa559a27].
chrstphrchvzwiki2023-04-27 07:10:08

scan abc {%2147483648$s} crashes on 8.6 and 8.7 as well. Can the fix and scan-19.3 be backported?

apnadkarnimarkdown2023-04-27 13:47:21

The back porting to 8.6/8.7 has relevance to all the "bigdata" tests and fixes, not just this one. In fact it also has relevance to 32-bit Tcl9.

However, these tests and fixes target bugs that are present for arguments with lengths that are valid for the build in question. So for 64-bit builds in Tcl9, 0x100000000 is a valid string / list length and that is what these tests and fixes address.

In particular, tests for lengths that are not supported by the build comprise a different set of tests and are harder to construct. They would be more appropriate for the 8.x series.

Also, given limited time and resources, I personally do not plan on spending any time making the 8.x series robust dealing with large data. I see that time better spent on 9.x.

So, the short answer after a long rationalization :-), no I'm not planning on a back port.

jan.nijtmansplain2023-04-27 13:56:49
> Can the fix and scan-19.3 be backported?

Anyone can implement/propose a backport for this fix to 8.6/8.7.
Log in (anonymous is fine) to add a comment.