Skip to content

Commit

Permalink
fix(orm): int overflows on arm build (#16108)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored May 11, 2023
1 parent d39f645 commit 384f012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit 384f012

Please sign in to comment.