Skip to content

Coverity flavored clang analyzer fixes#4774

Merged
pks-t merged 4 commits into
libgit2:masterfrom
tiennou:fix/clang-analyzer
Aug 24, 2018
Merged

Coverity flavored clang analyzer fixes#4774
pks-t merged 4 commits into
libgit2:masterfrom
tiennou:fix/clang-analyzer

Conversation

@tiennou
Copy link
Copy Markdown
Contributor

@tiennou tiennou commented Aug 21, 2018

It's that time of the year again (it's always that time).

A few potential crashers/fixes I've been sitting on, nothing really serious since we're client only but I'll defer to you on their severity.

At line 594, we do this :
if (error < 0)
		return error;

but if nothing was pushed in a GIT_SORT_TIME revwalk, we'd return
uninitialized stack data.
In case there was nothing to parse in the buf, we'd return uninitialized
stack data.
Otherwise we'll return stack data to the caller.
Otherwise we return a NULL context, which will get dereferenced in 
apply_credentials.
Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remote initialization is not required, but that remark is too small to warrant not merging this ;)

Comment thread src/mailmap.c
static int mailmap_add_buffer(git_mailmap *mm, const char *buf, size_t len)
{
int error;
int error = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah. In case len == 0 this can indeed be problematic

Comment thread src/remote.c
int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
{
git_remote *remote;
git_remote *remote = NULL;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initialization is not necessary. All lines before remote = git__calloc(1, sizeof(git_remote)) directly return and do not touch remote.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm just going full-paranoid for future-proofing 😉.

@pks-t pks-t merged commit 9a19310 into libgit2:master Aug 24, 2018
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Aug 24, 2018

Oh, I forgot: thanks! :P

@tiennou
Copy link
Copy Markdown
Contributor Author

tiennou commented Aug 24, 2018

My pleasure 😉.

@tiennou tiennou deleted the fix/clang-analyzer branch August 24, 2018 13:06
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Aug 27, 2018 via email

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.

2 participants