From: Andrew Price Date: Fri, 11 Nov 2016 13:29:00 +0000 Subject: [Cluster-devel] [PATCH] fsck.gfs2: Handle gfs2_readi() errors in check_statfs() Message-ID: <1478870940-30496-1-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Discovered by static analysis with clang. Related: rhbz#1394235 Signed-off-by: Andrew Price --- gfs2/fsck/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index c5967bc..51f3e03 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -170,9 +170,12 @@ static int check_statfs(struct gfs2_sbd *sdp) /* Read the current statfs values */ count = gfs2_readi(sdp->md.statfs, buf, 0, sdp->md.statfs->i_di.di_size); - if (count == sizeof(struct gfs2_statfs_change)) - gfs2_statfs_change_in(&sc, buf); - + if (count != sizeof(struct gfs2_statfs_change)) { + log_err(_("Failed to read statfs values (%d of %"PRIu64" read)\n"), + count, (uint64_t)sdp->md.statfs->i_di.di_size); + return FSCK_ERROR; + } + gfs2_statfs_change_in(&sc, buf); /* Calculate the real values from the rgrp information */ sdp->blks_total = 0; sdp->blks_alloced = 0; -- 2.7.4