]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: don't crash on -vv
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:34 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:00:59 +0000 (17:00 -0700)
A user reported a crash in xfs_repair when they run it with -vv
specified on the command line.  Ultimately this harks back to xfs_m in
main() containing uninitialized stack contents, and inadequate null
checks.  Fix both problems in one go.

Reported-by: Santiago Kraus <santiago_kraus@yahoo.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
repair/progress.c
repair/xfs_repair.c

index 07cf4e4f2baf7c08838515e4bc9694fbc863e68b..74e7a671962e61b830264c30e5f77ed93a9e7491 100644 (file)
@@ -394,7 +394,7 @@ timestamp(
        time_t                  now;
        struct tm               *tmp;
 
-       if (verbose > 1 && mp && mp->m_ddev_targp)
+       if (verbose > 1 && mp && mp->m_ddev_targp && mp->m_ddev_targp->bcache)
                cache_report(stderr, "libxfs_bcache", mp->m_ddev_targp->bcache);
 
        now = time(NULL);
index cf774964381e940d956ae8e08b0fb1ebb2772185..88aa7554201ba80318f0ed808d2108b72af5175a 100644 (file)
@@ -1018,7 +1018,7 @@ main(int argc, char **argv)
        xfs_mount_t     *temp_mp;
        xfs_mount_t     *mp;
        struct xfs_buf  *sbp;
-       xfs_mount_t     xfs_m;
+       struct xfs_mount xfs_m = { };
        struct xlog     log = {0};
        char            *msgbuf;
        struct xfs_sb   psb;