Skip to content

Commit

Permalink
Simplify TZif header checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
philr committed Sep 24, 2013
1 parent 5118250 commit bb033e5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/tzinfo/zoneinfo_timezone_info.rb
Expand Up @@ -108,7 +108,11 @@ def parse(file)
magic, version, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt, typecnt, charcnt =
check_read(file, 44).unpack('a4 a x15 NNNNNN')

if magic == 'TZif' && (version == '2' || version == '3') && RubyCoreSupport.time_supports_64bit
if magic != 'TZif'
raise InvalidZoneinfoFile, "The file '#{file.path}' does not start with the expected header."
end

if (version == '2' || version == '3') && RubyCoreSupport.time_supports_64bit
# Skip the first 32-bit section and read the header of the second 64-bit section
check_read(file, timecnt * 5 + typecnt * 6 + charcnt + leapcnt * 8 + ttisgmtcnt + ttisstdcnt)

Expand All @@ -122,8 +126,6 @@ def parse(file)
end

using_64bit = true
elsif magic != 'TZif'
raise InvalidZoneinfoFile, "The file '#{file.path}' does not start with the expected header."
elsif version != '3' && version != '2' && version != "\0"
raise InvalidZoneinfoFile, "The file '#{file.path}' contains a version of the zoneinfo format that is not currently supported."
else
Expand Down

0 comments on commit bb033e5

Please sign in to comment.