From 370f8ecaa9c9b3a968119e8fb735c3a35c92a0cc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 15 Sep 2017 14:15:41 -0700 Subject: [PATCH] Fix parsing of tzfile(5) files in QTimeZonePrivate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The leap second record sizes were not properly taken into account. The comments in the code were right, but not the code itself. Fortunately, on most Linux systems the leap seconds are not stored in the tzfiles, so we never ran into a parsing issue. Task-number: QTBUG-63205 Change-Id: I6e1fe42ae4b742a7b811fffd14e4a57f5d142f97 Reviewed-by: Maximilian Baumgartner Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_tz.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index 1714c9802f..4fdc2e36ac 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -277,8 +277,9 @@ static void parseTzLeapSeconds(QDataStream &ds, int tzh_leapcnt, bool longTran) { // Parse tzh_leapcnt x pairs of leap seconds // We don't use leap seconds, so only read and don't store - qint64 val; + qint32 val; if (longTran) { + // v2 file format, each entry is 12 bytes long qint64 time; for (int i = 0; i < tzh_leapcnt && ds.status() == QDataStream::Ok; ++i) { // Parse Leap Occurrence Time, 8 bytes @@ -288,6 +289,7 @@ static void parseTzLeapSeconds(QDataStream &ds, int tzh_leapcnt, bool longTran) ds >> val; } } else { + // v0 file format, each entry is 8 bytes long for (int i = 0; i < tzh_leapcnt && ds.status() == QDataStream::Ok; ++i) { // Parse Leap Occurrence Time, 4 bytes ds >> val;