It is possible that e2fsck_get_dir_info() returns a NULL pointer.
We do not want to blow up when dereferencing p. It seems to be
more sane/safe to call fix_problem(ctx, PR_3_NO_DIRINFO, pctx)
if p is NULL at this point since we do not have any DIRINFO
for pctx->ino.
Also fix another (already existing) error check for
e2fsck_get_dir_info() later in the function so that it reports the
correct inode number if the dirinfo information is not found for
p->parent.
(Both of these are "should-never-happen" internal e2fsck errors that
would indicate a programming bug of some kind.)
Coverity ID: 10: Null Returns
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-19 Theodore Tso <tytso@mit.edu>
+ * pass3.c (check_directory): Add error check in case
+ e2fsck_get_dir_info() returns NULL. Also fix another
+ error check for e2fsck_get_dir_info() to display the
+ correct inode number in case of this internal (should
+ never happen) error.
+
* pass1b.c (clone_file): Fix a coverity-found bug; add error
checking in case dict_lookup() returns NULL when looking up
an block or inode record after cloning the EA block.
ext2fs_unmark_valid(fs);
else {
p = e2fsck_get_dir_info(ctx, pctx->ino);
+ if (!p) {
+ fix_problem(ctx,
+ PR_3_NO_DIRINFO, pctx);
+ return 0;
+ }
p->parent = ctx->lost_and_found;
fix_dotdot(ctx, p, ctx->lost_and_found);
}
}
p = e2fsck_get_dir_info(ctx, p->parent);
if (!p) {
+ pctx->ino = p->parent;
fix_problem(ctx, PR_3_NO_DIRINFO, pctx);
return 0;
}