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

fix(orm): int overflows on arm build #16108

Merged
merged 3 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions orm/encoding/ormfield/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
)

const (
DurationSecondsMin = -315576000000
DurationSecondsMax = 315576000000
DurationNanosMin = -999999999
DurationNanosMax = 999999999
DurationSecondsMin int64 = -315576000000
DurationSecondsMax int64 = 315576000000
DurationNanosMin = -999999999
DurationNanosMax = 999999999
)

// DurationCodec encodes google.protobuf.Duration values with the following
Expand Down Expand Up @@ -41,7 +41,7 @@ func (d DurationCodec) Encode(value protoreflect.Value, w io.Writer) error {
return fmt.Errorf("duration seconds is out of range %d, must be between %d and %d", secondsInt, DurationSecondsMin, DurationSecondsMax)
}
negative := secondsInt < 0
// we subtract the min duration value to make sure secondsInt is always non-negative and starts at 0
// we subtract the min duration value to make sure secondsInt is always non-negative and starts at 0.
secondsInt -= DurationSecondsMin
err := encodeSeconds(secondsInt, w)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions orm/encoding/ormfield/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
type TimestampCodec struct{}

const (
timestampDurationNilValue = 0xFF
timestampDurationZeroNanosValue = 0x0
timestampDurationBufferSize = 9
TimestampSecondsMin = -62135596800
TimestampSecondsMax = 253402300799
TimestampNanosMax = 999999999
timestampDurationNilValue = 0xFF
timestampDurationZeroNanosValue = 0x0
timestampDurationBufferSize = 9
TimestampSecondsMin int64 = -62135596800
TimestampSecondsMax int64 = 253402300799
TimestampNanosMax = 999999999
)

var (
Expand Down