summaryrefslogtreecommitdiff
path: root/src/time/zoneinfo_read.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2018-12-27 14:23:29 -1000
committerJosh Bleecher Snyder <josharian@gmail.com>2019-02-27 18:08:03 +0000
commit58bf401293bd1de3740613f586b5b970dc991d39 (patch)
treecb10cbbd406c26d259aa37c44cfd766f3e55caa2 /src/time/zoneinfo_read.go
parent9892ccff23c94c5fabd704ff0c027d45b7b03cb8 (diff)
downloadgo-git-58bf401293bd1de3740613f586b5b970dc991d39.tar.gz
time: reject tzdata with no zones
Fixes #29437 Change-Id: Ice0a03a543e564d66651bfdfce5cd32ebaa35926 Reviewed-on: https://go-review.googlesource.com/c/155746 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/time/zoneinfo_read.go')
-rw-r--r--src/time/zoneinfo_read.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/time/zoneinfo_read.go b/src/time/zoneinfo_read.go
index d54632fb49..1e559a62cc 100644
--- a/src/time/zoneinfo_read.go
+++ b/src/time/zoneinfo_read.go
@@ -216,7 +216,13 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) {
// Now we can build up a useful data structure.
// First the zone information.
// utcoff[4] isdst[1] nameindex[1]
- zone := make([]zone, n[NZone])
+ nzone := n[NZone]
+ if nzone == 0 {
+ // Reject tzdata files with no zones. There's nothing useful in them.
+ // This also avoids a panic later when we add and then use a fake transition (golang.org/issue/29437).
+ return nil, badData
+ }
+ zone := make([]zone, nzone)
for i := range zone {
var ok bool
var n uint32