diff --git a/internal/datamanager/datamanager.go b/internal/datamanager/datamanager.go index ad06710..f890ef7 100644 --- a/internal/datamanager/datamanager.go +++ b/internal/datamanager/datamanager.go @@ -75,6 +75,8 @@ var ( const ( etcdChangeGroupMinRevisionRange = 1000 + + maxChangegroupNameLength = 256 ) type DataManagerConfig struct { diff --git a/internal/datamanager/wal.go b/internal/datamanager/wal.go index 5692fb2..188fd8a 100644 --- a/internal/datamanager/wal.go +++ b/internal/datamanager/wal.go @@ -19,6 +19,7 @@ import ( "container/ring" "context" "encoding/json" + "fmt" "io" "io/ioutil" "path" @@ -424,6 +425,18 @@ func (d *DataManager) WriteWal(ctx context.Context, actions []*Action, cgt *Chan } func (d *DataManager) WriteWalAdditionalOps(ctx context.Context, actions []*Action, cgt *ChangeGroupsUpdateToken, cmp []etcdclientv3.Cmp, then []etcdclientv3.Op) (*ChangeGroupsUpdateToken, error) { + // check changegroups name + if cgt != nil { + for cgName := range cgt.ChangeGroupsRevisions { + if strings.Contains(cgName, "/") { + return nil, fmt.Errorf(`changegroup name %q must not contain "/"`, cgName) + } + if len(cgName) > maxChangegroupNameLength { + return nil, fmt.Errorf("changegroup name %q too long", cgName) + } + } + } + if len(actions) == 0 { return nil, errors.Errorf("cannot write wal: actions is empty") }