Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

filter: fix SIGSEGV when stream return error#3659

Closed
chyh1990 wants to merge 1 commit intolibgit2:masterlibgit2/libgit2:masterfrom
chyh1990:fix-filterchyh1990/libgit2:fix-filterCopy head branch name to clipboard
Closed

filter: fix SIGSEGV when stream return error#3659
chyh1990 wants to merge 1 commit intolibgit2:masterlibgit2/libgit2:masterfrom
chyh1990:fix-filterchyh1990/libgit2:fix-filterCopy head branch name to clipboard

Conversation

@chyh1990
Copy link

@chyh1990 chyh1990 commented Mar 8, 2016

stream_start->close is called even stream_list_init() fails in git_filter_list_stream_data(),
but in this case, stream_start will be NULL, causing SIGSEGV.

@ethomson
Copy link
Member

ethomson commented Mar 8, 2016

Thanks for the fix! I'm curious if you have a unit test that you can create that will illustrate this problem?

I ask because after looking at this, and at the other users of git_writestream, the function git_filter_list_stream_data seems inconsistent when it comes to calling close. The close function is used to commit or finish (successfully) the stream.

As a result, it seems that the close should be moved out of the done block entirely... This would match the behavior of (for example) git_filter_list_stream_file. Is my thinking here correct?

@chyh1990
Copy link
Author

chyh1990 commented Mar 9, 2016

I discover this problem when i'm working on rust binding for libgit2. I can provide a unit test later.

The semantics of callbacks in git_writestream is not well-documented, if close is used to commit the stream, I think you're right, close should be moved out of done block.

@chyh1990
Copy link
Author

chyh1990 commented Mar 9, 2016

I find another problem, if you assume 'close' is used to commit a successful stream, in checkout.c, blob_content_to_file, after calling git_filter_list_stream_blob, it asserts writer.open == 0.

It seems to conflict with our assumption? because writer.close should never be called in a failure case.

@ethomson
Copy link
Member

Fixed via #4196

@ethomson ethomson closed this Apr 11, 2017
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.