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

Remove PartialEq between &str/String and Addr #1669

Closed
webmaster128 opened this issue Apr 21, 2023 · 0 comments · Fixed by #1879
Closed

Remove PartialEq between &str/String and Addr #1669

webmaster128 opened this issue Apr 21, 2023 · 0 comments · Fixed by #1879
Milestone

Comments

@webmaster128
Copy link
Member

When one of the sides is not normalized you can get unintended results. E.g.

fn my_func(deps: Deps, user_provided_address: &str) {

   let existing_address: Addr = CONFIG.load(deps.storage)?.blocked;

   if user_provided_address != blocked {
        return Err(ContractError::Unauthorized);
   }
}

Now if blocked is cosmos1jhg0e7s6gn44tfc5k37kr04sznyhedtc9rzys5 and user_provided_address is cosmos1jhg0e7s6gn44tfc5k37kr04sznyhedtc9rzys5 the check works fine. But if the perfectly valid form COSMOS1JHG0E7S6GN44TFC5K37KR04SZNYHEDTC9RZYS5 is provided, this breaks.

I'm sure the example is bad here but I hope you get what I mean. Equality checkes between Addr and &str or String are just not safe.

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

Successfully merging a pull request may close this issue.

1 participant