Skip to content

pqueue: resolve possible NULL pointer dereference#3976

Merged
pks-t merged 1 commit into
libgit2:masterfrom
pks-t:pks/pqueue-null-deref
Nov 2, 2016
Merged

pqueue: resolve possible NULL pointer dereference#3976
pks-t merged 1 commit into
libgit2:masterfrom
pks-t:pks/pqueue-null-deref

Conversation

@pks-t
Copy link
Copy Markdown
Member

@pks-t pks-t commented Oct 28, 2016

The git_pqueue struct allows being fixed in its total number of
entries. In this case, we simply throw away items that are
inserted into the priority queue by examining wether the new item
to be inserted has a higher priority than the previous smallest
one.

This feature somewhat contradicts our pqueue implementation in
that it is allowed to not have a comparison function. In fact, we
also fail to check if the comparison function is actually set in
the case where we add a new item into a fully filled fixed-size
pqueue.

As we cannot determine which item is the smallest item in absence
of a comparison function, we fix the NULL pointer dereference
by simply dropping all new items which are about to be inserted
into a full fixed-size pqueue.

The `git_pqueue` struct allows being fixed in its total number of
entries. In this case, we simply throw away items that are
inserted into the priority queue by examining wether the new item
to be inserted has a higher priority than the previous smallest
one.

This feature somewhat contradicts our pqueue implementation in
that it is allowed to not have a comparison function. In fact, we
also fail to check if the comparison function is actually set in
the case where we add a new item into a fully filled fixed-size
pqueue.

As we cannot determine which item is the smallest item in absence
of a comparison function, we fix the `NULL` pointer dereference
by simply dropping all new items which are about to be inserted
into a full fixed-size pqueue.
@pks-t pks-t merged commit 19001ca into libgit2:master Nov 2, 2016
@pks-t pks-t deleted the pks/pqueue-null-deref branch February 8, 2017 15:14
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.

1 participant