grpcproxy: reject invalid watch ranges

This commit is contained in:
Anthony Romano 2016-11-10 12:24:51 -08:00
parent ec459c2185
commit 395cf7de51
2 changed files with 8 additions and 0 deletions

View File

@ -213,6 +213,10 @@ func (wps *watchProxyStream) recvLoop() error {
progress: cr.ProgressNotify, progress: cr.ProgressNotify,
filters: v3rpc.FiltersFromRequest(cr), filters: v3rpc.FiltersFromRequest(cr),
} }
if !w.wr.valid() {
w.post(&pb.WatchResponse{WatchId: -1, Created: true, Canceled: true})
continue
}
wps.nextWatcherID++ wps.nextWatcherID++
w.nextrev = cr.StartRevision w.nextrev = cr.StartRevision
wps.watchers[w.id] = w wps.watchers[w.id] = w

View File

@ -27,6 +27,10 @@ type watchRange struct {
key, end string key, end string
} }
func (wr *watchRange) valid() bool {
return len(wr.end) == 0 || wr.end > wr.key || (wr.end[0] == 0 && len(wr.end) == 1)
}
type watcher struct { type watcher struct {
// user configuration // user configuration