From 6460dd9e034bf74b882f9f0e02a46ba1282a4d7e Mon Sep 17 00:00:00 2001 From: The3D Date: Tue, 10 Nov 2020 17:21:59 +0100 Subject: [PATCH] fixes #133 --- contracts/libraries/configuration/UserConfiguration.sol | 6 ++++++ contracts/libraries/helpers/Errors.sol | 1 + 2 files changed, 7 insertions(+) diff --git a/contracts/libraries/configuration/UserConfiguration.sol b/contracts/libraries/configuration/UserConfiguration.sol index 71c28f0e..8679390e 100644 --- a/contracts/libraries/configuration/UserConfiguration.sol +++ b/contracts/libraries/configuration/UserConfiguration.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; +import {Errors} from '../helpers/Errors.sol'; /** * @title UserConfiguration library * @author Aave @@ -24,6 +25,7 @@ library UserConfiguration { uint256 reserveIndex, bool borrowing ) internal { + require(reserveIndex < 128, Errors.UL_INVALID_INDEX); self.data = (self.data & ~(1 << (reserveIndex * 2))) | (uint256(borrowing ? 1 : 0) << (reserveIndex * 2)); @@ -40,6 +42,7 @@ library UserConfiguration { uint256 reserveIndex, bool _usingAsCollateral ) internal { + require(reserveIndex < 128, Errors.UL_INVALID_INDEX); self.data = (self.data & ~(1 << (reserveIndex * 2 + 1))) | (uint256(_usingAsCollateral ? 1 : 0) << (reserveIndex * 2 + 1)); @@ -56,6 +59,7 @@ library UserConfiguration { pure returns (bool) { + require(reserveIndex < 128, Errors.UL_INVALID_INDEX); return (self.data >> (reserveIndex * 2)) & 3 != 0; } @@ -70,6 +74,7 @@ library UserConfiguration { pure returns (bool) { + require(reserveIndex < 128, Errors.UL_INVALID_INDEX); return (self.data >> (reserveIndex * 2)) & 1 != 0; } @@ -84,6 +89,7 @@ library UserConfiguration { pure returns (bool) { + require(reserveIndex < 128, Errors.UL_INVALID_INDEX); return (self.data >> (reserveIndex * 2 + 1)) & 1 != 0; } diff --git a/contracts/libraries/helpers/Errors.sol b/contracts/libraries/helpers/Errors.sol index 2dff6ced..1aeb88b1 100644 --- a/contracts/libraries/helpers/Errors.sol +++ b/contracts/libraries/helpers/Errors.sol @@ -96,6 +96,7 @@ library Errors { string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = '72'; string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = '73'; string public constant LP_INCONSISTENT_PARAMS_LENGTH = '74'; + string public constant UL_INVALID_INDEX = '77'; enum CollateralManagerErrors { NO_ERROR,