]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e4defrag: don't crash if umounts the filesystem races with us
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 12 Dec 2013 18:07:33 +0000 (13:07 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 12 Dec 2013 18:07:34 +0000 (13:07 -0500)
If someone umounts the filesystem between statfs64() and the getmntent()
iteration, we can exit the loop having never set mnt_type, and strcmp
can crash.  Fix the potential NULL dereference.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/e4defrag.c

index 4b31d036293aebfbc9fb8ec0fad76a94a402041f..b6e2e319524320b94ea5642713478bbf993d73bf 100644 (file)
@@ -374,7 +374,7 @@ static int is_ext4(const char *file, char *devname)
        }
 
        endmntent(fp);
-       if (strcmp(mnt_type, FS_EXT4) == 0) {
+       if (mnt_type && strcmp(mnt_type, FS_EXT4) == 0) {
                FREE(mnt_type);
                return 0;
        } else {