]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Fix stupid core dumping bug if the TZ environment variable isn't set.
authorTheodore Ts'o <tytso@mit.edu>
Wed, 15 Dec 2004 17:21:41 +0000 (12:21 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 15 Dec 2004 17:21:41 +0000 (12:21 -0500)
debugfs/util.c
e2fsck/message.c

index ea82e32431d452fb54b28fb7dadae32d45e6d476..b1a66e8cfb221924eb8cb57af476c3bd0eba2896 100644 (file)
@@ -186,12 +186,16 @@ int check_fs_bitmaps(char *name)
  */
 char *time_to_string(__u32 cl)
 {
-       time_t  t = (time_t) cl;
-       static int do_gmt = -1;
+       static int      do_gmt = -1;
+       time_t          t = (time_t) cl;
+       char *          tz;
 
        if (do_gmt == -1) {
                /* The diet libc doesn't respect the TZ environemnt variable */
-               do_gmt = !strcmp(getenv("TZ"), "GMT");
+               tz = getenv("TZ");
+               if (!tz)
+                       tz = "";
+               do_gmt = !strcmp(tz, "GMT");
        }
 
        return asctime((do_gmt) ? gmtime(&t) : localtime(&t));
index a3250e13d8141558b1bfbf0dcc001ecb54bf5e27..342f3eaf9ceda415b5cfd831580435d11f4b23f8 100644 (file)
@@ -273,7 +273,10 @@ static _INLINE_ void expand_inode_expression(char ch,
        case 'M':
                /* The diet libc doesn't respect the TZ environemnt variable */
                if (do_gmt == -1) {
-                       do_gmt = !strcmp(getenv("TZ"), "GMT");
+                       time_str = getenv("TZ");
+                       if (!time_str)
+                               time_str = "";
+                       do_gmt = !strcmp(time_str, "GMT");
                }
                t = inode->i_mtime;
                time_str = asctime(do_gmt ? gmtime(&t) : localtime(&t));