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

Have a check on how the __addr_of intrinsic's result is used #2515

Open
vaivaswatha opened this issue Aug 11, 2022 · 1 comment
Open

Have a check on how the __addr_of intrinsic's result is used #2515

vaivaswatha opened this issue Aug 11, 2022 · 1 comment

Comments

@vaivaswatha
Copy link
Contributor

It's possible that we have a contract that has a function taking in an address (u64 value).

contract;
 abi Foo {
    fn bar(addr: u64);
} 

Then we have a script that calls this function bar as below:

script;
use Foo::bar;

fn something() {
    let x : b256 = 0x1111....;
    let x_addr = __addr_of(x);
    bar(x_addr);
}

This (using the address of a local variable in another program) should be statically analysed and disallowed as it violates memory safety (and causes a runtime failure).

@mohammadfawaz
Copy link
Contributor

I believe __addr_of now returns a raw_ptr which could make any analyses that we would like to do a bit easier.

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

2 participants