Commit 6ec5dc03 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Use consistent upper bound for authoritative match label size.

parent 4418a9ab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Add missing group chat channel message when a user is kicked from the group.
- Add missing group chat channel message when a user is promoted in the group.
- Handle TIMESTAMPTZ return types in Lua runtime custom SQL queries.
- Use consistent upper bound for authoritative match label size.

## [2.6.0] - 2019-07-01
### Added
+2 −2
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ var (
	MatchFilterPtr     = &MatchFilterValue
	MatchFilterRelayed = map[uint8]*uint8{StreamModeMatchRelayed: MatchFilterPtr}

	MaxLabelSize = 2048
	MatchLabelMaxBytes = 2048

	ErrMatchLabelTooLong     = errors.New("match label too long, must be 0-2048 bytes")
	ErrDeferredBroadcastFull = errors.New("too many deferred message broadcasts per tick")
@@ -214,7 +214,7 @@ func (r *LocalMatchRegistry) GetMatchLabel(ctx context.Context, id uuid.UUID, no
}

func (r *LocalMatchRegistry) UpdateMatchLabel(id uuid.UUID, label string) error {
	if len(label) > MaxLabelSize {
	if len(label) > MatchLabelMaxBytes {
		return ErrMatchLabelTooLong
	}

+2 −2
Original line number Diff line number Diff line
@@ -89,8 +89,8 @@ func NewRuntimeGoMatchCore(logger *zap.Logger, matchRegistry MatchRegistry, rout
func (r *RuntimeGoMatchCore) MatchInit(presenceList *MatchPresenceList, deferMessageFn RuntimeMatchDeferMessageFunction, params map[string]interface{}) (interface{}, int, error) {
	state, tickRate, label := r.match.MatchInit(r.ctx, r.runtimeLogger, r.db, r.nk, params)

	if len(label) > 256 {
		return nil, 0, errors.New("MatchInit returned invalid label, must be 256 bytes or less")
	if len(label) > MatchLabelMaxBytes {
		return nil, 0, fmt.Errorf("MatchInit returned invalid label, must be %v bytes or less", MatchLabelMaxBytes)
	}
	if tickRate > 30 || tickRate < 1 {
		return nil, 0, errors.New("MatchInit returned invalid tick rate, must be between 1 and 30")
+2 −2
Original line number Diff line number Diff line
@@ -208,8 +208,8 @@ func (r *RuntimeLuaMatchCore) MatchInit(presenceList *MatchPresenceList, deferMe
	r.vm.Pop(1)

	labelStr := label.String()
	if len(labelStr) > 256 {
		return nil, 0, errors.New("match_init returned invalid label, must be 256 bytes or less")
	if len(labelStr) > MatchLabelMaxBytes {
		return nil, 0, fmt.Errorf("match_init returned invalid label, must be %v bytes or less", MatchLabelMaxBytes)
	}

	// Extract desired tick rate.