Do Reentrancy Guards Protect against Both Single-Function and Cross-Function Attacks?
Yes, a properly implemented reentrancy guard can protect against both types of attacks. The guard typically uses a lock that is applied at the contract level, not just for a single function.
When any function with the guard modifier is entered, the lock is activated. If an external call from this function leads to a re-entrant call to any other function that also has the guard, the second function will see the lock is active and will revert the transaction.
This prevents both recursive calls to the same function and calls to other state-sharing functions within the contract.