bug-hurd
[Top][All Lists]
Advanced

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

Re: "" as target of symlink kills translator


From: Neal H Walfield
Subject: Re: "" as target of symlink kills translator
Date: Tue, 19 Jun 2001 17:30:46 -0500
User-agent: Mutt/1.3.18i

> > > Have you missed http://bugs.debian.org/78678 ?
> > 
> > This is the exact problem that I have fixed.
> 
> I just wondered if you were aware of it.  As your log shows,
> you have not fixed it in the way the report indicates, but avoided it
> by making "" an invalid argument (at resolve time) where we want it
> to behave like ".".  Even if EINVAL were what we wanted, we'd need the
> corresponding change to prevent creation of such links in the first place
> (but I think just treating them like a link to "." is okay).

Thank you for the explanation.  This is what you want, right?

neal@desdemona:~/foo (0)$ touch {a,b,c,d}
neal@desdemona:~/foo (0)$ ls -l ./
total 0
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 a
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 b
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 c
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 d
neal@desdemona:~/foo (0)$ ln -s . bar
neal@desdemona:~/foo (0)$ ls -l bar
lrwxr-xr-x    1 neal     neal            1 Jun 19 17:25 bar -> .
neal@desdemona:~/foo (0)$ ls bar/
a  b  bar  c  d
neal@desdemona:~/foo (0)$ rm bar
neal@desdemona:~/foo (0)$ ln -s "" bar
neal@desdemona:~/foo (0)$ ls -l bar
lrwxr-xr-x    1 neal     neal            0 Jun 19 17:25 bar -> 
neal@desdemona:~/foo (0)$ ls -l bar/
total 0
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 a
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 b
lrwxr-xr-x    1 neal     neal            0 Jun 19 17:25 bar -> 
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 c
-rw-r--r--    1 neal     neal            0 Jun 19 17:24 d
neal@desdemona:~/foo (0)$ rm bar
neal@desdemona:~/foo (0)$ exit

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

        * dir-lookup.c (diskfs_S_dir_lookup): When expanding symlinks,
        if we encounter "", replace it with "./".


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 22:28:30
@@ -339,13 +339,36 @@
          if (error)
            goto out;
 
-         if (nextname)
+         if (np->dn_stat.st_size == 0) /* i.e. symlink == "" */
            {
-             pathbuf[np->dn_stat.st_size] = '/';
-             bcopy (nextname, pathbuf + np->dn_stat.st_size + 1,
-                    nextnamelen - 1);
+             newnamelen += 2;
+             if (pathbuflen < newnamelen)
+               {
+                 pathbuf = alloca (newnamelen);
+                 pathbuflen = newnamelen;
+               }
+
+             pathbuf[0] = '.';
+             pathbuf[1] = '/';
+
+             if (nextname)
+               {
+                 bcopy (nextname, pathbuf + 2, nextnamelen - 1);
+                 pathbuf[nextnamelen + 1] = '\0';
+               }
+             else
+               pathbuf[2] = '\0';
            }
-         pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
+         else
+           {
+             if (nextname)
+               {
+                 pathbuf[np->dn_stat.st_size] = '/';
+                 bcopy (nextname, pathbuf + np->dn_stat.st_size + 1,
+                        nextnamelen - 1);
+               }
+             pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
+           }
 
          if (pathbuf[0] == '/')
            {

Attachment: pgpQkjbwGRvUO.pgp
Description: PGP signature


reply via email to

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