From 61bf29be36a6678ba16c457229ca306339ea4ebc Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Wed, 11 Mar 2015 10:43:52 -0500 Subject: Check length of timestring before taking slice --- logger/types.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/logger/types.go b/logger/types.go index d98f0874a..0f70578ba 100644 --- a/logger/types.go +++ b/logger/types.go @@ -8,7 +8,12 @@ import ( type utctime8601 struct{} func (utctime8601) MarshalJSON() ([]byte, error) { - return []byte(`"` + time.Now().UTC().Format(time.RFC3339Nano)[:26] + `Z"`), nil + timestr := time.Now().UTC().Format(time.RFC3339Nano) + // Bounds check + if len(timestr) > 26 { + timestr = timestr[:26] + } + return []byte(`"` + timestr + `Z"`), nil } type JsonLog interface { -- cgit v1.2.3