Skip to content

Commit

Permalink
Fix skipping unused portions in TimeZoneInfo::Load() for version 1 zo…
Browse files Browse the repository at this point in the history
…nefiles. (google#236)

In theory, leap-second record of version 1 zonefiles is 4 + 4 bytes per record.
https://www.rfc-editor.org/rfc/rfc8536.html#section-3.2

In practice, this commit won't make any difference because we return early
at line 437 if hdr.leapcnt != 0.

Co-authored-by: Shuo Chen <[email protected]>
  • Loading branch information
chenshuo and Shuo Chen authored Oct 31, 2022
1 parent 6caa145 commit c674330
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/time_zone_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,9 @@ bool TimeZoneInfo::Load(ZoneInfoSource* zip) {
// encoded zoneinfo. The ttisstd/ttisgmt indicators only apply when
// interpreting a POSIX spec that does not include start/end rules, and
// that isn't the case here (see "zic -p").
bp += (8 + 4) * hdr.leapcnt; // leap-time + TAI-UTC
bp += 1 * hdr.ttisstdcnt; // UTC/local indicators
bp += 1 * hdr.ttisutcnt; // standard/wall indicators
bp += (time_len + 4) * hdr.leapcnt; // leap-time + TAI-UTC
bp += 1 * hdr.ttisstdcnt; // UTC/local indicators
bp += 1 * hdr.ttisutcnt; // standard/wall indicators
assert(bp == tbuf.data() + tbuf.size());

future_spec_.clear();
Expand Down

0 comments on commit c674330

Please sign in to comment.