Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-06-27
10:56
Tests for [66ffafd309]. check-in: 20f491cd04 user: pooryorick tags: unchained
10:28
Fix [66ffafd309]. DBCS infinite loop on invalid encoding. check-in: 00c5e654f5 user: pooryorick tags: unchained
2023-07-05
14:59 • Ticket [66ffafd309] Truncated encoding for DBCS results in infinite loop and run... artifact: 2c0dad7e89 user: jan.nijtmans
14:55
Backport [66ffafd309]: Truncated encoding for DBCS results in infinite loop and running out of memor... check-in: 759e76383f user: jan.nijtmans tags: core-8-6-branch
2023-07-02
05:28 • Closed ticket [66ffafd309]: Truncated encoding for DBCS results in infinite loop... artifact: 86d848137c user: apnadkarni
04:55
Backport fix [66ffafd309]. DBCS infinite loop on invalid encoding check-in: 4d10e2c128 user: apnadkarni tags: core-8-branch
03:03
Tests for [66ffafd309] check-in: f5c08e6d36 user: apnadkarni tags: trunk, main
02:41
Fix [66ffafd309]. DBCS infinite loop on invalid encoding check-in: ffe33a7797 user: apnadkarni tags: trunk, main
2023-07-01
18:02
Bug [66ffafd309] closed check-in: 6ce225894f user: apnadkarni tags: bug-66ffafd309
16:24 • Ticket [66ffafd309] Truncated encoding for DBCS results in infinite loop and run... artifact: 36470d644b user: apnadkarni
15:13 • Ticket [66ffafd309]: 3 changes artifact: 6f0c9e411d user: chrstphrchvz
13:55 • Ticket [66ffafd309]: 3 changes artifact: 767c6f6499 user: apnadkarni
12:59 • Ticket [66ffafd309]: 3 changes artifact: 0f0b439b8f user: apnadkarni
12:54 • New ticket [66ffafd309]. artifact: b9e716237f user: apnadkarni

Truncated encoding for DBCS results in infinite loop and running out of memory

Closed / Fixed66ffafd309111bc7a5044c83636f5098b5804f43Created 3 years agoUpdated 3 years ago
Descriptionmarkdown2023-07-01 12:54:55
% encoding convertfrom gb12345 x

will run out of memory.

Referenced by7
apnadkarni Ticket [66ffafd309]: 3 changes [History diff]2023-07-01 12:59:30
apnadkarnimarkdown2023-07-01 13:55:03

Same test with 8.7

% encoding convertfrom gb12345 x
unexpected byte sequence starting at index 0: '\x78'

No infinite loop but still not what I would expect. With the default tcl8 profile, should not raise an error but instead store U+FFFD as is done for other encodings in case of truncation. For example,

% codep [encoding convertfrom utf-16 x]
U+00FFFD
chrstphrchvzwiki2023-07-01 15:13:43

In case it is related, note that [1bd796d9c2] also describes an infinite loop/memory exhaustion during enconding convertfrom.

apnadkarnimarkdown2023-07-01 16:24:20

Thanks but this is different. Seems to be related to this fix for this ticket.

Working on it.

apnadkarniplain2023-07-02 05:28:57
Fixed in [ffe33a7797] for 9.0 and [4d10e2c128] for 8.7.

Invalid / trailing truncated DBCS bytes are now mapped to same byte value (as is done for utf-8) when the tcl profile is in effect. 8.7 does not raise an error any more.
jan.nijtmanswiki2023-07-05 14:59:10

Trying the same in 8.6, "encoding convertfrom gb12345 x" gives the empty result which is equally surprising: Silently skipping bytes is never a good idea.

Therefore, I now backported the related changes to 8.6 as well [here]

Many thanks for tracking this down!

Log in (anonymous is fine) to add a comment.