oracle: add length check o.MainCfg.NeoFS.Nodes
Prevent the risk of a division by zero error when accessing the `o.MainCfg.NeoFS.Nodes[index]` array. Close #3419 Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
5c408f7fe4
commit
41109f442a
1 changed files with 5 additions and 0 deletions
|
@ -157,6 +157,11 @@ func (o *Oracle) processRequest(priv *keys.PrivateKey, req request) error {
|
||||||
resp.Code = transaction.Error
|
resp.Code = transaction.Error
|
||||||
}
|
}
|
||||||
case neofs.URIScheme:
|
case neofs.URIScheme:
|
||||||
|
if len(o.MainCfg.NeoFS.Nodes) == 0 {
|
||||||
|
o.Log.Warn("no NeoFS nodes configured", zap.String("url", req.Req.URL))
|
||||||
|
resp.Code = transaction.Error
|
||||||
|
break
|
||||||
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), o.MainCfg.NeoFS.Timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), o.MainCfg.NeoFS.Timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
index := (int(req.ID) + incTx.attempts) % len(o.MainCfg.NeoFS.Nodes)
|
index := (int(req.ID) + incTx.attempts) % len(o.MainCfg.NeoFS.Nodes)
|
||||||
|
|
Loading…
Reference in a new issue