Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix potential state corruption in UnmarshalJSON #10705

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@

// UnmarshalJSON implements the json.Unmarshaler interface.
// The time is expected to be a quoted string in RFC 3339 format.
func (t *TimeParts) UnmarshalJSON(data []byte) (err error) {
func (t *TimeParts) UnmarshalJSON(data []byte) error {

Check warning on line 40 in core/commands/add.go

View check run for this annotation

Codecov / codecov/patch

core/commands/add.go#L40

Added line #L40 was not covered by tests
// Fractional seconds are handled implicitly by Parse.
tt, err := time.Parse("\"2006-01-02T15:04:05Z\"", string(data))
if err != nil {
return err
}

Check warning on line 45 in core/commands/add.go

View check run for this annotation

Codecov / codecov/patch

core/commands/add.go#L43-L45

Added lines #L43 - L45 were not covered by tests
*t = TimeParts{&tt}
return
return nil

Check warning on line 47 in core/commands/add.go

View check run for this annotation

Codecov / codecov/patch

core/commands/add.go#L47

Added line #L47 was not covered by tests
}

type AddEvent struct {
Expand Down
Loading