Skip to content

Commit 43f92a7

Browse files
authored
Merge pull request #29 from datachainlab/audit-202409-s2-revise
S2-3: improve validations for `clientState.allowed_quote_statuses` and `clientState.allowed_advisory_ids` Signed-off-by: Jun Kimura <[email protected]>
2 parents 1d9086c + bf2266a commit 43f92a7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

contracts/ILCPClientErrors.sol

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ interface ILCPClientErrors {
1212
error LCPClientClientStateInvalidOperatorAddressLength();
1313
error LCPClientClientStateInvalidOperatorsNonce();
1414
error LCPClientClientStateUnexpectedOperatorsNonce(uint64 expectedNonce);
15+
error LCPClientClientStateInvalidAllowedQuoteStatus();
16+
error LCPClientClientStateInvalidAllowedAdvisoryId();
1517

1618
error LCPClientOperatorsInvalidOrder(address prevOperator, address nextOperator);
1719
error LCPClientClientStateInvalidOperatorsThreshold();

contracts/LCPClientBase.sol

+10-4
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ abstract contract LCPClientBase is ILightClient, ILCPClientErrors {
169169

170170
// set allowed quote status and advisories
171171
for (uint256 i = 0; i < clientState.allowed_quote_statuses.length; i++) {
172-
clientStorage.allowedStatuses.allowedQuoteStatuses[clientState.allowed_quote_statuses[i]] =
173-
AVRValidator.FLAG_ALLOWED;
172+
string memory allowedQuoteStatus = clientState.allowed_quote_statuses[i];
173+
if (bytes(allowedQuoteStatus).length == 0) {
174+
revert LCPClientClientStateInvalidAllowedQuoteStatus();
175+
}
176+
clientStorage.allowedStatuses.allowedQuoteStatuses[allowedQuoteStatus] = AVRValidator.FLAG_ALLOWED;
174177
}
175178
for (uint256 i = 0; i < clientState.allowed_advisory_ids.length; i++) {
176-
clientStorage.allowedStatuses.allowedAdvisories[clientState.allowed_advisory_ids[i]] =
177-
AVRValidator.FLAG_ALLOWED;
179+
string memory allowedAdvisoryId = clientState.allowed_advisory_ids[i];
180+
if (bytes(allowedAdvisoryId).length == 0) {
181+
revert LCPClientClientStateInvalidAllowedAdvisoryId();
182+
}
183+
clientStorage.allowedStatuses.allowedAdvisories[allowedAdvisoryId] = AVRValidator.FLAG_ALLOWED;
178184
}
179185

180186
return clientState.latest_height;

0 commit comments

Comments
 (0)