Overview
| Artifact ID: | 3dea659a0e74cbc474c6d960c96e6cf2fd2a97ac587d0cb7639a0c2370ed918a |
|---|---|
| Ticket: | 3e25ac512e9eeb8788028264c400238fcf425238
[file] inconsistent handling of VFS/.. |
| User & Date: | sebres on 2018-06-15 14:13:28 |
Changes
- icomment:
The same as regards the other file commands using TclpObjStat / TclOSstat (at least by the second call)... <pre style="padding-left:10pt"><code> % file exists [string trim " /etc/passwd/.. "] 1 % file exists [pwd] 1 % file exists [string trim " /etc/passwd/.. "] 0 </code></pre> Strange is if I extend TclpObjStat with path normalization (that normally should do always the same thing), it works?! <pre style="padding-left:10pt"><code> --- "a/./unix/tclUnixFile.c~0" +++ "b/./unix/tclUnixFile.c" @@ -842,7 +842,20 @@ TclpObjStat( if (path == NULL) { return -1; } else { <b style="color:red;">- return TclOSstat(path, bufPtr);</b> <b style="color:green;">+ int rc = TclOSstat(path, bufPtr); + if (rc == -1 + #ifdef ENOTDIR + && errno == ENOTDIR + #endif + ) { + Tcl_Obj *normPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr); + if (normPtr == NULL) { + return -1; + } + path = Tcl_GetString(normPtr); + rc = TclOSstat(path, bufPtr); + } + return rc;</b> } } </code></pre> So I assume that not only the file access resp. file system api selecter is affected, <b>but also the precedence of the path normalization:</b><ul> <li>rather it should always firstly resolve the path-segments;</li> <li>or the path-segments, that could be really accessed by corresponding file-system (and only hereafter the rest);</li> <li>or it remains UB as now;</li> </ul> Currently we've a mix there, although very confusing mix. So firstly I would like to know the expected precedence regarding path-segments and file access. Or answer to question: should <code>[file dirname "/some/path"]</code> point to the same path as "/some/path/..", and if not, which deviations there are? - login: "sebres"
- mimetype: "text/x-fossil-wiki"