Commit a0757bb5 authored by Dave Kleikamp's avatar Dave Kleikamp

Detect bad JFS directory to avoid infinite loop

parent 5e4b5079
...@@ -3045,6 +3045,14 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -3045,6 +3045,14 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
t = (dtslot_t *) & p->slot[next]; t = (dtslot_t *) & p->slot[next];
name_ptr += outlen; name_ptr += outlen;
d_namleft -= len; 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); len = min(d_namleft, DTSLOTDATALEN);
outlen = jfs_strfromUCS_le(name_ptr, t->name, outlen = jfs_strfromUCS_le(name_ptr, t->name,
len, codepage); len, codepage);
...@@ -3056,6 +3064,7 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -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, if (filldir(dirent, d_name, d_namlen, filp->f_pos,
le32_to_cpu(d->inumber), DT_UNKNOWN)) le32_to_cpu(d->inumber), DT_UNKNOWN))
goto out; goto out;
skip_one:
if (!do_index) if (!do_index)
dtoffset->index++; dtoffset->index++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment