Whamcloud - gitweb
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 4b31d03..b6e2e31 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 {