From acb79d9d19737cdd3c64bfd83c101fdeed47766e Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 15 Dec 2004 12:21:41 -0500 Subject: [PATCH] Fix stupid core dumping bug if the TZ environment variable isn't set. --- debugfs/util.c | 10 +++++++--- e2fsck/message.c | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/debugfs/util.c b/debugfs/util.c index ea82e32..b1a66e8 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -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)); diff --git a/e2fsck/message.c b/e2fsck/message.c index a3250e1..342f3ea 100644 --- a/e2fsck/message.c +++ b/e2fsck/message.c @@ -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)); -- 1.8.3.1