Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-12-03
01:18 • Ticket [849514ffff] Absolute pathnames with ../ and links status still Open ... artifact: 024b76ed78 user: vincentdarley
2004-12-02
08:30 • Ticket [849514ffff]: 5 changes artifact: 48e2790f07 user: dgp
2004-11-18
01:31 • Ticket [849514ffff]: 4 changes artifact: a4d368402e user: dgp
00:46 • Ticket [849514ffff]: 1 change artifact: a625163740 user: hobbs
2004-02-18
09:04 • Open ticket [849514ffff]. artifact: 3903b79ab9 user: hobbs
08:37 • Closed ticket [849514ffff]. artifact: 54bddd6dbc user: hobbs
2004-02-06
09:37 • Ticket [849514ffff]: 5 changes artifact: 7d830e18e6 user: hobbs
2003-12-13
00:30 • Add attachment linknorm.diff to ticket [849514ffff] artifact: b05e439b1d user: vincentdarley
00:30 • Ticket [849514ffff] Absolute pathnames with ../ and links status still Open ... artifact: 12849f1aa8 user: vincentdarley
2003-12-11
19:58 • Ticket [849514ffff]: 5 changes artifact: ac78285779 user: vincentdarley
18:53 • Ticket [849514ffff]: 4 changes artifact: 657e36cd48 user: vincentdarley
00:35 • Ticket [849514ffff]: 4 changes artifact: 68a9843124 user: vincentdarley
2003-12-10
19:32 • Ticket [849514ffff]: 4 changes artifact: f183aafe43 user: vincentdarley
19:22 • Ticket [849514ffff]: 5 changes artifact: 0fd09cbb77 user: vincentdarley
19:17 • Ticket [849514ffff]: 4 changes artifact: 4d95d2fea4 user: vincentdarley
2003-11-27
14:32 • Open ticket [849514ffff]. artifact: f424657836 user: vulpeculus
01:00 • Closed ticket [849514ffff]. artifact: dc149dcf69 user: hobbs
2003-11-26
09:07 • New ticket [849514ffff]. artifact: 7b83bdfd5b user: vulpeculus

Absolute pathnames with ../ and links

Open849514ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 22 years ago
Descriptionplain2003-11-26 09:07:49
This concerns Tcl  on Unix (Solaris 8, Solaris 9, RH
Linux Kernel 2.4.?):

When trying to open a file (e.g. [open $filename r])
with an absolute pathname containing symbolic links and
../ (parent directory), a wrong file is referenced:
e.g. if  /home/somedir is a link to /root/otherdir then
trying to open /home/somedir/../file opens /home/file
instead of /root/file

In Tcl 8.3.1 open worked as expected. The first Tcl
version which I can test and has the problem is 8.4.1
hobbsplain2003-11-27 01:00:11
Logged In: YES 
user_id=72656

This works for me in 8.4.5 on linux:

ln -s /tmp/dist /home/
tclsh
 % open /home/dist/../jeffh/.cshrc
 file4

So this should have been checked against the latest release 
before submitting.
vulpeculusplain2003-11-27 14:32:08
Logged In: YES 
user_id=917954

The bug IS still ion 8.4.5. What I wanted to say that it
probably first occured between 8.3.1 and 8.4.1.

In your example /home/dist is a link to /tmp/dist
So /home/dist/../jeffh/.cshrc is /tmp/jeffh/.cshrc, not
/home/jeffh/.cshrc (try it e.g. with ls in any shell).
However, as long as you do not have a file
/tmp/jeffh/.cshrc, the open command from your example should
return an error "no such file or directory", instead of
opening the wrong file.

The same behaviour can also be found with a non-existing
directory in your pathname:
open /home/jeffh/nonexistentdir/../.cshrc
fails in 8.3.1 (correct), but succeeds in 8.4.5 (incorrect)
vincentdarleyplain2003-12-10 19:17:38
Logged In: YES 
user_id=32170

This behaviour is all down to 'file normalize', so if this
bug report is correct, you should be able to show that 'file
normalize' returns the wrong path for some input strings
containing ../

Can you please try to provide one or two examples?
vincentdarleyplain2003-12-10 19:22:57
Logged In: YES 
user_id=32170

Here's a simple example on Windows:

file mkdir tclfoo
cd tclfoo

file mkdir one/two/three
file link link one/two/three
file normalize link/../foo

# The result:
E:/tclfoo/foo
# It should be:
E:/tclfoo/one/two/foo
vincentdarleyplain2003-12-10 19:32:43
Logged In: YES 
user_id=32170

The bug is quite clear now.  TclFSNormalizeAbsolutePath
removes all '.' and '..' sequences before passing the path
to the platform-specific normalization code. But, the '..'
removal is done in a purely string-based way, with no
awareness of symlinks at all.

We probably need to remove that whole block of code (lines
149-173 of tclPathObj.c) and make each platform-specific
piece of code a bit cleverer.

This might actually improve performance, since it would
remove the need for a whole file split/file join pair in the
current approach (but replace it with more complex
platform-specific code).
vincentdarleyplain2003-12-11 00:35:47
File Added - 70181: linknorm.diff

Logged In: YES 
user_id=32170

Please test the attached patch (to Tcl 8.5a0)
vincentdarleyplain2003-12-11 18:53:10
File Deleted - 70181: 



File Added - 70242: linknorm.diff
vincentdarleyplain2003-12-11 19:58:19
File Deleted - 70242: 



File Added - 70250: linknorm.diff

Logged In: YES 
user_id=32170

Updated patch.  Needs testing on unix, but should then be
ready to go.

Jeff: could you test this please?
vincentdarleyplain2003-12-13 00:30:23
File Deleted - 70250: 



File Added - 70363: linknorm.diff

Logged In: YES 
user_id=32170

Updated patch for cvs head.
hobbsplain2004-02-06 09:37:31
Logged In: YES 
user_id=72656

We will also need an 8.4-based patch.
hobbsplain2004-02-18 08:37:35
Logged In: YES 
user_id=72656

backported for 8.4.6.
hobbsplain2004-02-18 09:04:21
Logged In: YES 
user_id=72656

had to revert because the changes were not properly
isolated, and the 8.5 changes are a lot more spread out than
expected.  Don't know quite what to backport ...
hobbs Ticket [849514ffff]: 1 change [History diff]2004-11-18 00:46:41
dgpplain2004-11-18 01:31:12
Logged In: YES 
user_id=80530

This matter is related to 961646.

Both are rooted in the fact that
Tcl's Tcl_Filesystem layer is
imposing one interpretation of
 ".." in a path instead of leaving
it up to each (native) filesystem
to use its own preferences.
dgpplain2004-12-02 08:30:41
Logged In: YES 
user_id=80530

dropping priority since this
can't be "fixed" until the
differences of opinion about
the correct design of the
VFS layer laid out in 961646
are addressed.

this won't be fixed in Tcl 8.4.9.
vincentdarleyplain2004-12-03 01:18:26
Logged In: YES 
user_id=32170

I don't know if I agree with dgp's comment that each
filesystem should have its own interpretation of '..'. 
Surely they should be the same?  (At least that's what's in
Tcl 8.5)
Log in (anonymous is fine) to add a comment.

Attachments: