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
20f491cd04Tests for [66ffafd309]. check-in2024-06-27 10:56:4200c5e654f5Fix [66ffafd309]. DBCS infinite loop on invalid encoding. check-in2024-06-27 10:28:00759e76383fBackport [66ffafd309]: Truncated encoding for DBCS results in infinite loop and running out of memory check-in2023-07-05 14:55:514d10e2c128Backport fix [66ffafd309]. DBCS infinite loop on invalid encoding check-in2023-07-02 04:55:47f5c08e6d36Tests for [66ffafd309] check-in2023-07-02 03:03:30ffe33a7797Fix [66ffafd309]. DBCS infinite loop on invalid encoding check-in2023-07-02 02:41:596ce225894fBug [66ffafd309] check-in2023-07-01 18:02:07
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
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.