mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-18 05:56:37 +00:00
Check length of timestring before taking slice
This commit is contained in:
parent
58909117be
commit
61bf29be36
1 changed files with 6 additions and 1 deletions
|
|
@ -8,7 +8,12 @@ import (
|
||||||
type utctime8601 struct{}
|
type utctime8601 struct{}
|
||||||
|
|
||||||
func (utctime8601) MarshalJSON() ([]byte, error) {
|
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 {
|
type JsonLog interface {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue