Tcl Source Code

View Ticket
Login
Ticket UUID: 941108
Title: TclpObjNormalizePath(unix) breaks VFS spec
Type: Bug Version: obsolete: 8.5a2
Submitter: dgp Created on: 2004-04-24 02:10:40
Subsystem: 37. File System Assigned To: dgp
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2004-04-26 22:52:03
Resolution: Fixed Closed By: dgp
    Closed on: 2004-04-26 15:52:03
Description:
The Tcl_FSNormalizePathProc of a 
Tcl_Filesystem gets three arguments,

  (TclInterp *interp,
   Tcl_Obj *pathPtr,
   int nextCheckPoint)

and an int return value.

It's spelled out in in the Tcl_Filesystem
docs that both nextCheckPoint and
the returned value should be indices
into the pathPtr->bytes array and the
value should point to either the start
(0) the end (bytes[cp] == '\0') or
to a separator character, usually '/'.

The unix TclpObjNormalizePath()
routine does not follow these rules;
it returns a value that points "one past"
the separator, not to it.

The correction is simple, just remove
lines 1805-1807 from unix/tclUnixFCmd.c
Those lines incorrectly advance the
checkpoint value one past where it
ought to be.

Removing those lines leads to no
new failures in the test suite on three
different unix systems I tried.
User Comments: vincentdarley added on 2004-04-26 22:40:34:
Logged In: YES 
user_id=32170

Oh yes, I would commit the simpler one now (no 'access'
check), but consider adding the other check in place if/when
the needs of the other discussions/fixes require it.

dgp added on 2004-04-26 22:32:18:
Logged In: YES 
user_id=80530

which one?

The additional access() call
is helpful when there are
other FS's registered, as it
will let the native FS claim
the entire path when it can.

However, when there's only
a native FS around, the
additional access() call
adds to the overhead of path
normaliztaion.

Intermingled with this is
Bug 931847.  The plans
for revising Tcl_FSNTUP
might influence the choice.

vincentdarley added on 2004-04-26 22:15:23:
Logged In: YES 
user_id=32170

Please do commit the fix.

dgp added on 2004-04-24 10:00:23:

File Added - 84878: 941108.patch

Logged In: YES 
user_id=80530


Even better, in addition to removing
those lines, it appears that 
TclpObjNormalizePath can claim
to have normalized the whole thing
rather than just all but the final
component via this patch.

Attachments: