Merge branch 'fix/133' into 'master'

Resolve "Add validation on UserConfiguration that the reserveIndex is < 128"

Closes #133

See merge request aave-tech/protocol-v2!151
This commit is contained in:
The-3D 2020-11-10 16:29:11 +00:00
commit 74ab2fd126
2 changed files with 7 additions and 0 deletions

View File

@ -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;
}

View File

@ -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,