From f22386423c50bd298b197779a6ed6616f716576e Mon Sep 17 00:00:00 2001 From: zorzal Date: Tue, 10 Dec 2024 13:02:10 -0500 Subject: [PATCH] fix: ensure input arrays have the same length --- solidity/contracts/Oracle.sol | 6 +++++- solidity/interfaces/IOracle.sol | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/solidity/contracts/Oracle.sol b/solidity/contracts/Oracle.sol index 9283cb9..36a112d 100644 --- a/solidity/contracts/Oracle.sol +++ b/solidity/contracts/Oracle.sol @@ -111,8 +111,12 @@ contract Oracle is IOracle, OracleAccessController { AccessControl[] calldata _accessControl ) external returns (bytes32[] memory _batchRequestsIds) { uint256 _requestsAmount = _requestsData.length; - _batchRequestsIds = new bytes32[](_requestsAmount); + if (_requestsAmount != _ipfsHashes.length || _requestsAmount != _accessControl.length) { + revert Oracle_ArrayMismatchLength(); + } + + _batchRequestsIds = new bytes32[](_requestsAmount); for (uint256 _i; _i < _requestsAmount;) { _batchRequestsIds[_i] = _createRequest(_requestsData[_i], _ipfsHashes[_i], _accessControl[_i]); unchecked { diff --git a/solidity/interfaces/IOracle.sol b/solidity/interfaces/IOracle.sol index 6246de7..9c93cc4 100644 --- a/solidity/interfaces/IOracle.sol +++ b/solidity/interfaces/IOracle.sol @@ -168,6 +168,11 @@ interface IOracle is IOracleAccessController { */ error Oracle_InvalidDisputer(); + /** + * @notice Thrown when the input arrays have different lengths + */ + error Oracle_ArrayMismatchLength(); + /*/////////////////////////////////////////////////////////////// ENUMS //////////////////////////////////////////////////////////////*/