]> git.hungrycats.org Git - linux/commitdiff
Detect bad JFS directory to avoid infinite loop
authorDave Kleikamp <shaggy@kleikamp.austin.ibm.com>
Thu, 4 Apr 2002 04:01:01 +0000 (22:01 -0600)
committerDave Kleikamp <shaggy@kleikamp.austin.ibm.com>
Thu, 4 Apr 2002 04:01:01 +0000 (22:01 -0600)
fs/jfs/jfs_dtree.c

index 3a8e77ca11b9c0a61aa3a318db9719bc6624cd6c..c705239305808124099f8706ec4e452658f2d6fc 100644 (file)
@@ -3045,6 +3045,14 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                                t = (dtslot_t *) & p->slot[next];
                                name_ptr += outlen;
                                d_namleft -= len;
+                               /* Sanity Check */
+                               if (d_namleft == 0) {
+                                       jERROR(1,("JFS:Dtree error: "
+                                         "ino = %ld, bn=%Ld, index = %d\n",
+                                                 ip->i_ino, bn, i));
+                                       updateSuper(ip->i_sb, FM_DIRTY);
+                                       goto skip_one;
+                               }
                                len = min(d_namleft, DTSLOTDATALEN);
                                outlen = jfs_strfromUCS_le(name_ptr, t->name,
                                                           len, codepage);
@@ -3056,6 +3064,7 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                        if (filldir(dirent, d_name, d_namlen, filp->f_pos,
                                    le32_to_cpu(d->inumber), DT_UNKNOWN))
                                goto out;
+skip_one:
                        if (!do_index)
                                dtoffset->index++;
                }