I have a pay ETH function in my smart contract. I deployed it ages ago and only just realized it might be vulnerable to reentrancy attacks.
Is it? I know that the msg.sender.transfer() max gas is 2300 but I don't know if its still vulnerable..
function payETH() external payable {
uint256 amount = msg.value;
uint256 existing = ethLoaned[msg.sender];
if (amount > existing) {
msg.sender.transfer(amount - existing);
amount = existing;
}
ethLoaned[msg.sender] -= amount;
emit Payback(msg.sender, amount);
}