Whamcloud - gitweb
Fix debugfs coredump when lsdel is run without an open filesystem
authorTheodore Ts'o <tytso@mit.edu>
Tue, 29 Aug 2006 21:02:56 +0000 (17:02 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 29 Aug 2006 21:02:56 +0000 (17:02 -0400)
Addresses Debian Bug: #378335

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs/ChangeLog
debugfs/lsdel.c

index 3373908..c451651 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-29  Theodore Tso  <tytso@mit.edu>
+
+       * lsdel.c (do_lsdel): Fix core-dumping bug.  Don't depend on
+               current_fs being non-NULL until after the call to
+               common_args_process().  (Addresses Debian Bug: #378335)
+
 2006-05-29  Theodore Tso  <tytso@mit.edu>
 
        * util.c (reset_getopt): In order to support ancient Linux header
index 774b88e..d815eb2 100644 (file)
@@ -81,12 +81,13 @@ void do_lsdel(int argc, char **argv)
        int                     i;
        long                    secs = 0;
        char                    *tmp;
-       time_t                  now = current_fs->now ? current_fs->now : time(0);
+       time_t                  now;
        FILE                    *out;
        
        if (common_args_process(argc, argv, 1, 2, "ls_deleted_inodes",
                                "[secs]", 0))
                return;
+
        if (argc > 1) {
                secs = strtol(argv[1],&tmp,0);
                if (*tmp) {
@@ -95,6 +96,7 @@ void do_lsdel(int argc, char **argv)
                }
        }
 
+       now = current_fs->now ? current_fs->now : time(0);
        max_delarray = 100;
        num_delarray = 0;
        delarray = malloc(max_delarray * sizeof(struct deleted_info));