bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"" as target of symlink kills translator


From: Neal H Walfield
Subject: "" as target of symlink kills translator
Date: Tue, 19 Jun 2001 15:04:05 -0500
User-agent: Mutt/1.3.18i

Take the following:

        Script started on Tue Jun 19 14:23:07 2001
        neal@desdemona:~ (0)$ sudo settrans -acP foo /hurd/ext2fs \
        > /dev/hd2s9
        Translator pid: 336
        Pausing...
        neal@desdemona:~ (0)$ cd foo
        neal@desdemona:~/foo (0)$ ln -s "" baz
        neal@desdemona:~/foo (0)$ rm baz
        rm: cannot unlink `baz': (os/kern) invalid right
        neal@desdemona:~/foo (1)$ exit
        Script done on Tue Jun 19 14:26:51 2001

So what happened?  Let us take a look at what gdb caught:

        neal@desdemona:~ (0)$ sudo gdb /hurd/ext2fs 336
        GNU gdb 5.0
        ...
        [Switching to thread 336.1]
        (gdb) c
        Continuing.
        warning: Can't wait for pid 336: No child processes

        Program received signal EXC_BAD_ACCESS, Could not access memory.
        [Switching to thread 336.3]
        0x1034157 in diskfs_S_dir_lookup (dircred=0x805d868, path=0x126debc
        "baz", 
        flags=0, mode=0, retry=0x126bec4, retryname=0x126becc "", 
        returned_port=0x126c2d0, returned_port_poly=0x126bdc4)
        at ../../../src/hurd/libdiskfs/dir-lookup.c:392
        
        392    type = np->dn_stat.st_mode & S_IFMT;
        (gdb) quit
        The program is running.  Quit anyway (and detach it)? (y or n) y
        Detaching from program `/hurd/ext2fs' pid 336
        neal@desdemona:~ (0)$

Strange, NP was NULL.  We should have looked up the target of the
symlink and either errored out with ENOENT or found the corresponding
node.  However, to do that, we would have had to pass the loop
condition a few lines earlier:

        } while (path && *path);

Unfortunentaly, the perfectly valid filename "" drops us out of the
loop, which, to say the least, is not what we want.

Here is a patch:

libdiskfs/ChangeLog:

2001-06-19  Neal H Walfield  <neal@cs.uml.edu>

        * dir-lookup.c (diskfs_S_dir_lookup): If the target of a symlink
        is "", we drop out of the lookup loop without looking "" up.
        Continue explicitly whenever we expand a symlink.

Index: dir-lookup.c
===================================================================
RCS file: /home/neal/cvs/hurd/libdiskfs/dir-lookup.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 dir-lookup.c
--- dir-lookup.c        2001/06/16 22:41:55     1.1.1.2
+++ dir-lookup.c        2001/06/19 20:02:20
@@ -87,6 +87,7 @@
 
   diskfs_nref (dnp);           /* acquire a reference for later diskfs_nput */
 
+search_again:
   do
     {
       assert (!lastcomp);
@@ -366,6 +367,13 @@
            }
          diskfs_nput (np);
          np = 0;
+         
+         /* We are sure that PATH contains a sometime otherwise, we
+            would have errored out just after the call to
+            diskfs_node_rdwr.  As PATH could be "", we must explicitly
+            continue as otherwise, the loop condititional could be
+            wrong.  */
+         goto search_again;
        }
       else
        {

Attachment: pgp_PVjly59s3.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]