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

Type check the tree value for Rugged::Index#read_tree #401

Merged
merged 2 commits into from
Aug 22, 2014

Conversation

adelcambre
Copy link
Contributor

libgit2 does no type checking in git_index_read_tree which means that
index.read_tree will segfault if you pass something other than a tree.

This ensures that the value passed is actually a tree.

Andy Delcambre added 2 commits August 22, 2014 13:56
libgit2 does no type checking in `git_index_read_tree` which means that
`index.read_tree` will segfault if you pass something other than a tree.

This ensures that the value passed is actually a tree.
@adelcambre
Copy link
Contributor Author

Also, I'm not sure if this should be handled in libgit2 as well. I was chatting with @arrbee and he indicated that rugged is a better place for this sort of type checking.

@carlosmn
Copy link
Member

libgit2, being in C, has static type checking. The function accepts a git_tree * so any decent C code should have the right type anyway. Of course, being in C, you could pass in a pointer to whatever and still make it crash. Since it's rugged the one that's casting between types, I agree it's the one which should be making sure the passed-in object is the right one.

arthurschreiber added a commit that referenced this pull request Aug 22, 2014
Type check the tree value for Rugged::Index#read_tree
@arthurschreiber arthurschreiber merged commit ab675f8 into master Aug 22, 2014
@arthurschreiber
Copy link
Member

Looks great, thanks!

arthurschreiber added a commit that referenced this pull request Aug 22, 2014
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 this pull request may close these issues.

None yet

3 participants