]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
[COVERITY] Check for NULL return from dict_lookup() in e2fsck
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 19 Mar 2007 12:52:10 +0000 (08:52 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 19 Mar 2007 12:52:10 +0000 (08:52 -0400)
The dict_lookup() function can potentially return a NULL dnode_t.  It is
not checked in two places in the clone_file() function.  Looks to be
safe to continue if n is NULL, so just print a warning message and
continue.

Coverity ID: 9: Null Returns

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/ChangeLog
e2fsck/pass1b.c

index dd0524d4900d46a8a60669ad83f550e6109ca907..0d530c00886be3d8057c2bf25b95a1184e13642b 100644 (file)
@@ -1,5 +1,9 @@
 2007-03-19  Theodore Tso  <tytso@mit.edu>
 
+       * 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.
+
        * profile.c (profile_init, get_dirlist): Fix bug where if a
                profile directory is completely empty, the profile library
                would segfault.
index cec60cf460954319ce6dab50b5e7e640e3d9b7b1..ae2b15a4db7f01aa3d218fd1a13695c4e3e8a7ba 100644 (file)
@@ -752,11 +752,26 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
                 * them to point to the new EA block.
                 */
                n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk));
+               if (!n) {
+                       com_err("clone_file", 0, 
+                               _("internal error: couldn't lookup EA "
+                                 "block record for %u"), blk);
+                       retval = 0; /* OK to stumble on... */
+                       goto errout;
+               }
                db = (struct dup_block *) dnode_get(n);
                for (ino_el = db->inode_list; ino_el; ino_el = ino_el->next) {
                        if (ino_el->inode == ino)
                                continue;
                        n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode));
+                       if (!n) {
+                               com_err("clone_file", 0, 
+                                       _("internal error: couldn't lookup EA "
+                                         "inode record for %u"), 
+                                       ino_el->inode);
+                               retval = 0; /* OK to stumble on... */
+                               goto errout;
+                       }
                        di = (struct dup_inode *) dnode_get(n);
                        if (di->inode.i_file_acl == blk) {
                                di->inode.i_file_acl = dp->inode.i_file_acl;