NetBSD-Bugs archive

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

Re: kern/43963: libsa cd9660.c pathname lookup problem



Hi again,

so I looked closer at the problem.  Turns out that it's got nothing
to do with the order of the path table entries, which is generated
correctly by both mkisofs and makefs.

The problem is that the code doesn't handle the very first entry in
the path table, i.e. the entry for the root directory, correctly.
The attached patch fixes this.  While here, it also fixes a minor
bug, where the old code (would it have worked) would not allow multiple
path separators betwween directory entries, i.e. it would not find
i386///binary/kernel//netbsd_install_floppy.gz.

As a minor nit to the original PR, the instructions in How-to-Repeat
can't work anyway, as the 9660 boot code currently only supports
original 9660 filenames (albeit allowing for lower/upper case conversion)
which doesn't allow the '-' character in filenames.  You have to type

boot i386/binary/kernel/netbsd_INSTALL_FLOPPY.gz

to get the desired kernel (works, of course, only with the patch applied.)

Ciao,
Wolfgang
--
Wolfgang%Solfrank.net@localhost                          Wolfgang Solfrank
Index: sys/lib/libsa/cd9660.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/cd9660.c,v
retrieving revision 1.25
diff -u -r1.25 cd9660.c
--- sys/lib/libsa/cd9660.c      22 Mar 2010 16:57:54 -0000      1.25
+++ sys/lib/libsa/cd9660.c      13 Oct 2010 13:24:42 -0000
@@ -190,19 +190,25 @@
                goto out;
        }
 
-       parent = 1;
        pp = (struct ptable_ent *)buf;
-       ent = 1;
+       /*
+        * The first entry is always the root directory.
+        * Since this has a special name in it, handle it separately.
+        */
+       parent = 1;
        bno = isonum_732(pp->block) + isonum_711(pp->extlen);
+       pp = (struct ptable_ent *)((char *)pp + PTSIZE(pp));
+       ent = 2;
 
        rc = ENOENT;
-       /*
-        * Remove extra separators
-        */
-       while (*path == '/')
-               path++;
 
        while (*path) {
+               /*
+                * Remove extra separators
+                */
+               while (*path == '/')
+                       path++;
+
                if ((char *)pp >= (char *)buf + psize)
                        break;
                if (isonum_722(pp->parent) != parent)
@@ -212,7 +218,7 @@
                        ent++;
                        continue;
                }
-               path += isonum_711(pp->namlen) + 1;
+               path += isonum_711(pp->namlen);
                parent = ent;
                bno = isonum_732(pp->block) + isonum_711(pp->extlen);
                while ((char *)pp < (char *)buf + psize) {


Home | Main Index | Thread Index | Old Index