bug-hurd
[Top][All Lists]
Advanced

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

Bug#78678: hurd: symlink to empty name crashes libdiskfs


From: Roland McGrath
Subject: Bug#78678: hurd: symlink to empty name crashes libdiskfs
Date: Sun, 3 Dec 2000 17:22:42 -0500 (EST)

We should figure out what behavior we want.  In Linux 2.2, it is impossible
to create a symlink with empty contents (symlink returns ENOENT).  In
FreeBSD 4.1, you can create a symlink to empty--and it acts like a symlink
to /.  What I would have expected was that it act like a symlink to ., but
it is easy to see how an implementation could wind up acting like FreeBSD
appears to.

That said, I hacked this patch, which might work.  The intent of this patch
is to make a symlink to empty behave like a symlink to ., but I have not
even tried to compile this.


Index: dir-lookup.c
===================================================================
RCS file: /cvs/hurd/libdiskfs/dir-lookup.c,v
retrieving revision 1.44
diff -u -b -p -r1.44 dir-lookup.c
--- dir-lookup.c     2000/03/17 10:36:19        1.44
+++ dir-lookup.c     2000/12/03 22:22:03
@@ -333,6 +333,12 @@ diskfs_S_dir_lookup (struct protid *dirc
     if (error)
         goto out;
 
+         if (np->dn_stat.st_size == 0)
+             /* We don't want to prepend a leading slash to NEXTNAME,
+                    we just want to continue with it as it is.  */
+                        path = nextname;
+                          else
+                              {
                                 if (nextname)
                                     {
                                           pathbuf[np->dn_stat.st_size] =
                                           pathbuf[np->'/';
@@ -351,6 +357,7 @@ diskfs_S_dir_lookup (struct protid *dirc
       }
 
          path = pathbuf;
+             }
                if (lastcomp)
                    {
                          lastcomp = 0;
@@ -378,6 +385,14 @@ diskfs_S_dir_lookup (struct protid *dirc
       dnp = 0;
       }
     } while (path && *path);
+
+  if (np == 0)
+    {
+      assert (!newnode);
+      assert (dnp != 0);
+      np = dnp;
+      dnp = 0;
+    }
 
   /* At this point, np is the node to return.  If newnode is set, then
      we just created this node.  */




reply via email to

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