diff options
author | Dimitri John Ledkov <dimitri.j.ledkov@intel.com> | 2015-08-19 10:03:58 +0000 |
---|---|---|
committer | Dimitri John Ledkov <dimitri.j.ledkov@intel.com> | 2015-08-19 10:04:00 +0000 |
commit | 8c4fa32acf82c9567554268d13e2fecb2f18813c (patch) | |
tree | 4f38d39640288b835b328f12e6132319b9e7bf1f | |
parent | 4105232edccf0b02e7376a6877d29f3ddf512082 (diff) |
timedatectl: assert timezone is not null in setenv() call.
setenv is declared as:
extern int setenv (const char *__name, const char *__value, int __replace)
__THROW __nonnull ((2));
And i->timezone can be NULL, if for example /etc/localtime is
missing. Previously that worked, but now result in a libc dumping
core, as seen with gcc 2.22, due to:
https://sourceware.org/ml/glibc-cvs/2015-q2/msg00075.html
-rw-r--r-- | src/timedate/timedatectl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 240578bca0..8ec6adb493 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -96,7 +96,7 @@ static void print_status_info(const StatusInfo *i) { old_tz = strdupa(tz); /* Set the new $TZ */ - if (setenv("TZ", i->timezone, true) < 0) + if (i->timezone && setenv("TZ", i->timezone, true) < 0) log_warning_errno(errno, "Failed to set TZ environment variable, ignoring: %m"); else tzset(); |