Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about is_reentrant function #2623

Open
Tonyrj3268 opened this issue Jan 5, 2025 · 0 comments
Open

question about is_reentrant function #2623

Tonyrj3268 opened this issue Jan 5, 2025 · 0 comments

Comments

@Tonyrj3268
Copy link

HI, I'm studying your code to better understand this tool.

While reviewing the is_reentrant property method, I noticed a behavior that I find curious.
Specifically, I know that under certain conditions, the function returns True. But, my understanding is that if a function is neither public nor external, and it also does not have any external entry points, it should not be susceptible to reentrancy. Therefore, I am puzzled as to why the line1575 returns True in such cases, suggesting that the function might be reentrant?
Thank you for your assistance!

def is_reentrant(self) -> bool:
"""
Determine if the function can be re-entered
"""
reentrancy_modifier = "nonReentrant"
if self.function_language == FunctionLanguage.Vyper:
reentrancy_modifier = "nonreentrant(lock)"
# TODO: compare with hash of known nonReentrant modifier instead of the name
if reentrancy_modifier in [m.name for m in self.modifiers]:
return False
if self.visibility in ["public", "external"]:
return True
# If it's an internal function, check if all its entry points have the nonReentrant modifier
all_entry_points = [
f for f in self.all_reachable_from_functions if f.visibility in ["public", "external"]
]
if not all_entry_points:
return True
return not all(
(reentrancy_modifier in [m.name for m in f.modifiers] for f in all_entry_points)
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant