Skip to content

Commit

Permalink
Merge pull request #13575 from AdamKorcz/fuzz1
Browse files Browse the repository at this point in the history
v2auth: fix out of bounds in test
  • Loading branch information
spzala authored Jan 16, 2022
2 parents b8c5d44 + 6aac35d commit f4266e2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/etcdserver/api/v2auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ func (td *testDoer) Do(_ context.Context, req etcdserverpb.Request) (etcdserver.
}, nil
}
if (req.Method == "GET" || req.Method == "QGET") && td.get != nil {
if td.getindex >= len(td.get) {
return etcdserver.Response{}, &v2error.Error{
ErrorCode: v2error.EcodeKeyNotFound,
}
}
res := td.get[td.getindex]
if res.Event == nil {
td.getindex++
Expand All @@ -187,6 +192,11 @@ func (td *testDoer) Do(_ context.Context, req etcdserverpb.Request) (etcdserver.
return res, nil
}
if req.Method == "PUT" && td.put != nil {
if td.putindex >= len(td.put) {
return etcdserver.Response{}, &v2error.Error{
ErrorCode: v2error.EcodeKeyNotFound,
}
}
res := td.put[td.putindex]
if res.Event == nil {
td.putindex++
Expand Down

0 comments on commit f4266e2

Please sign in to comment.