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

Ini::section and Ini::index abuse a soundness hole #19

Closed
arielb1 opened this issue Oct 1, 2015 · 4 comments
Closed

Ini::section and Ini::index abuse a soundness hole #19

arielb1 opened this issue Oct 1, 2015 · 4 comments
Assignees
Labels

Comments

@arielb1
Copy link

arielb1 commented Oct 1, 2015

The relevant code is

    pub fn section<'a: 'i, 'p>(&'a self, name: Option<&'p str>) -> Option<&'i Properties<'pk, 'pv>> {
        self.sections.get(&name.map(|s| s.into()))
    }

You access the sections HashMap, which has the type &'a HashMap<Option<Cow<'i, str>, _>, and you try to access it with an Option<Cow<'p, str>>. The lifetime mismatch is not detected by Rust 1.5, but will be detected by future versions of rustc.

index has a similar problem.

The only fix I am aware of is to turn the Cow to an owned one.

@zonyitoo
Copy link
Owner

zonyitoo commented Oct 1, 2015

Hmm, you are correct. Would you fire an PR?

@arielb1
Copy link
Author

arielb1 commented Oct 1, 2015

@zonyitoo

Would adding an allocation there be too bad?

@zonyitoo
Copy link
Owner

zonyitoo commented Oct 1, 2015

It shouldn't be too complicated to make all data to be owned by the Ini instance. Just replace all Cow to their owned version should be Ok.

I use Cow here just for learning how lifetime works (This is my first Rust project).

@zonyitoo
Copy link
Owner

zonyitoo commented Oct 2, 2015

I am going to fix this.

@zonyitoo zonyitoo self-assigned this Oct 2, 2015
@zonyitoo zonyitoo added the bug label Oct 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants