Skip to content

Commit

Permalink
xattr.c: fix incorrect error handling in get_xattrs()
Browse files Browse the repository at this point in the history
Fix incorrect error handling in get_xattrs() which leads
to Mksquashfs failing to read the filesystem on appending.

get_xattrs() originally collected error results in res,
and then returned res as the function result.
Suucess would fall through with res containing
the correct result.

Unfortunately, a recent commit introduced a failed
flag returned by get_xattr() which is logically
reversed (TRUE fail, FALSE success).  Fall through
in the success case therefore now returns the wrong
error code.

Fix this by removing the fall through of res, and
just return TRUE, with error conditions also
directly returning rather than jumping to the end
of the function.

This fixes the error and also simplifies the code,
removing the unnecessary label and jumps.

Reported-by: Kevin Vigor <kvigor@gmail.com>
Signed-off-by: Phillip Lougher <plougher@redhat.com>
  • Loading branch information
Phillip Lougher committed Sep 12, 2019
1 parent d6d5c71 commit 81e9fe7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions squashfs-tools/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ int get_xattrs(int fd, struct squashfs_super_block *sBlk)

res = read_xattrs_from_disk(fd, sBlk, FALSE, NULL);
if(res == SQUASHFS_INVALID_BLK || res == 0)
goto done;
return res;
ids = res;

/*
Expand All @@ -664,13 +664,11 @@ int get_xattrs(int fd, struct squashfs_super_block *sBlk)
*/
if(id != i) {
ERROR("BUG, different xattr_id in get_xattrs\n");
res = 0;
goto done;
return FALSE;
}
}

done:
return res;
return TRUE;
}


Expand Down

0 comments on commit 81e9fe7

Please sign in to comment.