mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-12-25 01:40:55 +08:00
[COVERITY] Check for NULL return from dict_lookup() in e2fsck
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>
This commit is contained in:
parent
d2021de5cf
commit
538e654c25
@ -1,5 +1,9 @@
|
|||||||
2007-03-19 Theodore Tso <tytso@mit.edu>
|
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.c (profile_init, get_dirlist): Fix bug where if a
|
||||||
profile directory is completely empty, the profile library
|
profile directory is completely empty, the profile library
|
||||||
would segfault.
|
would segfault.
|
||||||
|
@ -752,11 +752,26 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
|
|||||||
* them to point to the new EA block.
|
* them to point to the new EA block.
|
||||||
*/
|
*/
|
||||||
n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk));
|
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);
|
db = (struct dup_block *) dnode_get(n);
|
||||||
for (ino_el = db->inode_list; ino_el; ino_el = ino_el->next) {
|
for (ino_el = db->inode_list; ino_el; ino_el = ino_el->next) {
|
||||||
if (ino_el->inode == ino)
|
if (ino_el->inode == ino)
|
||||||
continue;
|
continue;
|
||||||
n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode));
|
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);
|
di = (struct dup_inode *) dnode_get(n);
|
||||||
if (di->inode.i_file_acl == blk) {
|
if (di->inode.i_file_acl == blk) {
|
||||||
di->inode.i_file_acl = dp->inode.i_file_acl;
|
di->inode.i_file_acl = dp->inode.i_file_acl;
|
||||||
|
Loading…
Reference in New Issue
Block a user