[#1461] node: Do not accept lock object w/o expiration

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-05-31 20:10:04 +03:00 committed by fyrchik
parent de31bb27b6
commit 25826bd96d

View file

@ -260,9 +260,19 @@ func (v *FormatValidator) ValidateContent(o *object.Object) error {
return errors.New("missing ID")
}
// check that LOCK object has correct expiration epoch
lockExp, err := expirationEpochAttribute(o)
if err != nil {
return fmt.Errorf("lock object expiration epoch: %w", err)
}
if currEpoch := v.netState.CurrentEpoch(); lockExp <= currEpoch {
return fmt.Errorf("lock object expiration: %d; current: %d", lockExp, currEpoch)
}
var lock object.Lock
err := lock.Unmarshal(o.Payload())
err = lock.Unmarshal(o.Payload())
if err != nil {
return fmt.Errorf("decode lock payload: %w", err)
}