Overview
| Artifact ID: | 4dd9da46fd8b0b4f91e8a51d9ad543dd28e5e81b8f9b273bc7e9e74b7871d6df |
|---|---|
| Ticket: | f2ff05fc8411be80a93913b2b065f2c85fa9bcf0
Usage of static systemEncoding is not thread safe (vulnerability) |
| User & Date: | sebres on 2024-04-26 14:45:45 |
Changes
- icomment:
The encoding cache introduced there doesn't have a goal to improve performance only - the second major job, it does, is a protection of "vulnerable" call <i>Tcl_GetEncodingName(NULL)</i> (see [./artifact?name=9ad1b5848330ad5f&ln=984-987|lines 984-987] for details).<br/> The issue is - so as it is constructed, it is impossible to repair completely, because this function doesn't imply a decrement of reference or free of returned name, so the caller may use a pointer later, which can be released by switch of system encoding (e. g. by other threads). Now the cache avoids that situation, as long as the system encoding would not be switched too often (hardly imaginable in normal regular case, that 4 threads switch it to more than 4 different encodings at once).<br/> The fully correct fix would only work with thread-based encoding (TSD, etc), but then not backwards compatible anymore.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"