mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
grpcproxy: reject invalid watch ranges
This commit is contained in:
parent
ec459c2185
commit
395cf7de51
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user