Overview
| Artifact ID: | ffe6b06dd3b2509befaf4d9e4b146ef8f0ea3ce1 |
|---|---|
| Ticket: | 3603434fffffffffffffffffffffffffffffffff
Win TclpObjNormalizePath fails for non-existent drive |
| User & Date: | dgp on 2013-02-05 16:38:31 |
Changes
- assignee changed to: "dgp"
- cmimetype changed to: "text/plain"
- comment changed to:
The portions of filesystem pathname handling in the generic/*.c files of Tcl include special per-platform handling of [file pathtype] queries. In particular, on Windows, any pathname starting with ?:/ , where ? is any single byte, gets labeled as an absolute path based on the assumption that it's a drive designation. This happens whether or not such a drive is actually on the system. Over in the tclWinFile.c implementation of TclpObjNormalizePath(), though, a normalization of a path of the same pattern, say "a:/", is more constrained. If the "a" drive is not actually on the system (floppy drives are uncommon now), it refuses to declare that "a:/" is a normalized pathname. Instead, it claims "a:" is a normalized pathname, and leaves the rest for other filesystems to continue normalizing. This is trouble and inconsistent. The cooperative normalization process relies on working on an absolute pathname, and this misstep leaves us with a volumerelative one. It's also inconsistent with the rules imposed in the generic code. Most of the time this bug is harmless, because no other filesystem is present or makes an effort to claim, and the final fallback is to give it native ownership and just assume what's left is normalized. This turns out to be correct. The only time this causes trouble is when the Tcl_FSNormalizePathProc of some other Tcl_Filesystem recursively calls for a prefix of the path to be normalized as part of its own attempt to normalize more of the path. For example, this is what trofs does. Then the bug leads to endless recursion and a crash when the stack is exhausted. Thanks to Brian Griffin for taking notice of this. Demonstration isn't difficult. On Windows, bring trofs into an interp and then attempt a [glob a:/] on a system with no A: drive. CRASH! The simplest way to restore consistency is to make sure TclpObjNormalizePath claims the first / in the path as part of a normalized path, whether or not the drive exists on the system. Then the assumptions of the cooperative normalization among Tcl_Filesystems are maintained and crashes are avoided. To be clear, this is not the "most correct" solution. Getting something more correct involves some serious rewriting so that platform processing is better contained in platform files. This is a minimal consistency and sanity and crash prevention fix given the state of things as they are.
- foundin changed to: "None"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "dgp"
- subsystem changed to: "36. Pathname Management"
- title changed to:
Win TclpObjNormalizePath fails for non-existent drive
- type changed to: "Bug"