MEDIUM severity: The `StrategyManager` contract is responsible for managing deposits and withdrawals from strategies.. The `StrategyManager` contract is responsible for managing deposits and withdrawals from strategies. The `deposit` and `withdraw` functions are critical components of this process, as they facilitate the transfer of assets between the strategy and the `StrategyManager`. However, these functions are...

Vulnerable code:
```\nfunction withdraw(address depositor, IERC20 token, uint256 amountShares)\n    external\n    virtual\n    override\n    onlyWhenNotPaused(PAUSED_WITHDRAWALS)\n    onlyStrategyManager\n{\n    require(token == underlyingToken, "StrategyBase.withdraw: Can only withdraw the strategy token");\n    uint256 priorTotalShares = totalShares;\n    require(amountShares <= priorTotalShares, "StrategyBase.withdraw: amountShares must be less than or equal to totalShares");\n\n    uint256 updatedTotalShares = priorTotalShares - amountShares;\n    require(updatedTotalShares >= MIN_NONZERO_TOTAL_SHARES || updatedTotalShares == 0, "StrategyBase.withdraw: updated totalShares amount would be nonzero but below MIN_NONZERO_TOTAL_SHARES");\n\n    totalShares = updatedTotalShares;\n\n    uint256 amountToSend;\n    if (priorTotalShares == amountShares) {\n        amountToSend = _tokenBalance();\n    } else {\n        amountToSend = (_tokenBalance() * amountShares) / priorTotalShares;\n    }\n\n    underlyingToken.safeTransfer(depositor, amountToSend);\n}\n```\n```\nfunction sharesToUnderlyingView(uint256 amountShares) public view virtual override returns (uint256) {\n    if (totalShares == 0) {\n        return amountShares;\n    } else {\n        return (_tokenBalance() * amountShares) / totalShares;\n    }\n}\n```\n```\nfunction _depositIntoStrategy(address depositor, IStrategy strategy, IERC20 token, uint256 amount)\n    internal\n    onlyStrategiesWhitelistedForDeposit(strategy)\n    returns (uint256 shares)\n{\n    token.safeTransferFrom(msg.sender, address(strategy), amount);\n\n    shares = strategy.deposit(token, amount);\n}\n```\n```\nfunction deposit(IERC20 token, uint256 amount)\n    external\n    virtual\n    override\n    onlyWhenNotPaused(PAUSED_DEPOSITS)\n    onlyStrategyManager\n    returns (uint256 newShares)\n{\n    require(token == underlyingToken, "StrategyBase.deposit: Can only deposit underlyingToken");\n\n    uint256 priorTokenBalance = _tokenBalance() - amount;\n    if (priorTokenBalance == 0 || totalShares == 0) {\n        newShares = amount;\n    } else {\n        newShares = (amount * totalShares) / priorTokenBalance;\n    }\n\n    require(newShares!= 0, "StrategyBase.deposit: newShares cannot be zero");\n    uint256 updatedTotalShares = totalShares + newShares;\n    require(updatedTotalShares >= MIN_NONZERO_TOTAL_SHARES,\n        "StrategyBase.deposit: updated totalShares amount would be nonzero but below MIN_NONZERO_TOTAL_SHARES");\n\n    totalShares = updatedTotalShares;\n    return newShares;\n}\n```\n```\nfunction depositIntoStrategyWithSignature(\n    IStrategy strategy,\n    IERC20 token,\n    uint256 amount,\n    address staker,\n    uint256 expiry,\n    bytes memory signature\n)\n    external\n    onlyWhenNotPaused(PAUSED_DEPOSITS)\n    onlyNotFrozen(staker)\n    nonReentrant\n    returns (uint256 shares)\n{\n    require(\n        expiry >= block.timestamp,\n        "StrategyManager.depositIntoStrategyWithSignature: signature expired"\n    );\n\n    uint256 nonce = nonces[staker];\n    bytes32 structHash = keccak256(abi.encode(DEPOSIT_TYPEHASH, strategy, token, amount, nonce, expiry));\n    unchecked {\n        nonces[staker] = nonce + 1;\n    }\n    bytes32 digestHash = keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, structHash));\n\n    if (Address.isContract(staker)) {\n        require(IERC1271(staker).isValidSignature(digestHash, signature) == ERC1271_MAGICVALUE,\n            "StrategyManager.depositIntoStrategyWithSignature: ERC1271 signature verification failed");\n    } else {\n        require(ECDSA.recover(digestHash, signature) == staker,\n            "StrategyManager.depositIntoStrategyWithSignature: signature not from staker");\n    }\n\n    shares = _depositIntoStrategy(staker, strategy, token, amount);\n}\n```