diff options
author | Martin Klapetek <mklapetek@kde.org> | 2015-12-04 16:00:57 -0500 |
---|---|---|
committer | Martin Klapetek <mklapetek@kde.org> | 2015-12-07 18:03:17 +0000 |
commit | 891c98ebd63b5a5b079a1f5a2736a29d89afcbd2 (patch) | |
tree | cac1faf6a1e60e34e5d9b3d60dba7aa988dd250c /src/corelib | |
parent | 9dde61f4b3519b4de5b83fab463c8d8136baf5b6 (diff) |
Don't treat "/etc/localtime" in TZ env var as a valid timezone id
On some Debian distros, the TZ environment variable can be set to
":/etc/localtime", which libc defines as "default value". If this is
set, the current QTimeZone parsing code will return "/etc/localtime"
as the system timezone id, which is clearly wrong.
So in that case, just unset the ianaId variable and let the other
blocks look for the timezone.
Change-Id: I3f5795d0a05f4974a60556387a07a1e2e1e7aa30
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qtimezoneprivate_tz.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index 90ce8e3b68..85ed345869 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -918,6 +918,13 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const if (!ianaId.isEmpty() && ianaId.at(0) == ':') ianaId = ianaId.mid(1); + // The TZ value can be ":/etc/localtime" which libc considers + // to be a "default timezone", in which case it will be read + // by one of the blocks below, so unset it here so it is not + // considered as a valid/found ianaId + if (ianaId == "/etc/localtime") + ianaId.clear(); + // On Debian Etch and later /etc/localtime is real file with name held in /etc/timezone if (ianaId.isEmpty()) { QFile tzif(QStringLiteral("/etc/timezone")); |