Package: hurd
Version: 2000-08-02

Hi,

isofs died on some symlinks. I found out that it used to realloc a double
sized buffer when adding a path component, but this might not be enough:
The old path plus the new component can be longer than the current alloced
buffer mulitplied with 2.

Then I noticed all targets start with garbage, because after malloc() some
space is already claimed by setting targused to a non-zero value.

Then I noticed that it didn't even recognized there were symlinks, because
VALID_SL is not set.

Then I noticed that it dies on me, because read_diskinode uses the name
field and not the target field to get the link target, which might be 0x0.

Then it worked :) I can check it in if you like, it's tested and all.

Thanks,
Marcus

2000-08-02  Marcus Brinkmann  <[EMAIL PROTECTED]>

        * rr.c (rrip_work): In helper function add_comp
        set targused to zero after malloc, and loop over
        realloc in case doubling is not enough.
        After finalizing the link, set VALID_SL valid flag.
        * inode.c (read_disknode): For links use rl->target
        instead rl->name.

diff -ru hurd/isofs/inode.c /mnt/marcus/gnu/hurd/hurd/hurd-20000726/isofs/inode.c
--- hurd/isofs/inode.c  Sun Dec 27 11:19:38 1998
+++ /mnt/marcus/gnu/hurd/hurd/hurd-20000726/isofs/inode.c       Wed Aug  2 18:44:55 
+2000
@@ -410,8 +410,8 @@
     {
       if (rl->valid & VALID_SL)
        {
-         np->dn->link_target = rl->name;
-         rl->name = 0;
+         np->dn->link_target = rl->target;
+         rl->target = 0;
          st->st_size = strlen (np->dn->link_target);
        }
       else
diff -ru hurd/isofs/rr.c /mnt/marcus/gnu/hurd/hurd/hurd-20000726/isofs/rr.c
--- hurd/isofs/rr.c     Sun Nov 21 05:28:48 1999
+++ /mnt/marcus/gnu/hurd/hurd/hurd-20000726/isofs/rr.c  Wed Aug  2 18:26:03 2000
@@ -363,10 +363,10 @@
              if (rr->target == 0)
                {
                  rr->target = malloc (cnamelen * 2);
-                 targused = cnamelen;
+                 targused = 0;
                  targalloced = cnamelen * 2;
                }
-             else if (targused + cnamelen > targalloced)
+             else while (targused + cnamelen > targalloced)
                rr->target = realloc (rr->target, targalloced *= 2);
              assert (rr->target);
 
@@ -434,6 +434,8 @@
            rr->target[targused - 1] = '\0';
          else
            add_comp ("", 1);
+
+         rr->valid |= VALID_SL;
 
          free (slbuf);
          goto next_field;

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org Check Key server 
Marcus Brinkmann              GNU    http://www.gnu.org    for public PGP Key 
[EMAIL PROTECTED],     [EMAIL PROTECTED]    PGP Key ID 36E7CD09
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/       [EMAIL PROTECTED]

Reply via email to