Skip to content

Commit

Permalink
S2-3: improve validations for clientState.allowed_quote_statuses an…
Browse files Browse the repository at this point in the history
…d `clientState.allowed_advisory_ids`

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Nov 26, 2024
1 parent 1d9086c commit bf2266a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions contracts/ILCPClientErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface ILCPClientErrors {
error LCPClientClientStateInvalidOperatorAddressLength();
error LCPClientClientStateInvalidOperatorsNonce();
error LCPClientClientStateUnexpectedOperatorsNonce(uint64 expectedNonce);
error LCPClientClientStateInvalidAllowedQuoteStatus();
error LCPClientClientStateInvalidAllowedAdvisoryId();

error LCPClientOperatorsInvalidOrder(address prevOperator, address nextOperator);
error LCPClientClientStateInvalidOperatorsThreshold();
Expand Down
14 changes: 10 additions & 4 deletions contracts/LCPClientBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,18 @@ abstract contract LCPClientBase is ILightClient, ILCPClientErrors {

// set allowed quote status and advisories
for (uint256 i = 0; i < clientState.allowed_quote_statuses.length; i++) {
clientStorage.allowedStatuses.allowedQuoteStatuses[clientState.allowed_quote_statuses[i]] =
AVRValidator.FLAG_ALLOWED;
string memory allowedQuoteStatus = clientState.allowed_quote_statuses[i];
if (bytes(allowedQuoteStatus).length == 0) {
revert LCPClientClientStateInvalidAllowedQuoteStatus();
}
clientStorage.allowedStatuses.allowedQuoteStatuses[allowedQuoteStatus] = AVRValidator.FLAG_ALLOWED;
}
for (uint256 i = 0; i < clientState.allowed_advisory_ids.length; i++) {
clientStorage.allowedStatuses.allowedAdvisories[clientState.allowed_advisory_ids[i]] =
AVRValidator.FLAG_ALLOWED;
string memory allowedAdvisoryId = clientState.allowed_advisory_ids[i];
if (bytes(allowedAdvisoryId).length == 0) {
revert LCPClientClientStateInvalidAllowedAdvisoryId();
}
clientStorage.allowedStatuses.allowedAdvisories[allowedAdvisoryId] = AVRValidator.FLAG_ALLOWED;
}

return clientState.latest_height;
Expand Down

0 comments on commit bf2266a

Please sign in to comment.