[systemd-devel] [PATCH] journal: avoid NULL pointer dereference in chain_cache_put

Lennart Poettering lennart at poettering.net
Mon Oct 27 15:22:57 PDT 2014


On Mon, 27.10.14 23:36, philippedeswert at gmail.com (philippedeswert at gmail.com) wrote:

> From: Philippe De Swert <philippedeswert at gmail.com>
> 
> ordered_hashmap_steal_first() can return NULL (and this is usually checked
> except here), so there is a potential NULL pointer reference.
> Thus moving the NULL check to cover both possible allocations of the
> ChainCacheItem.

We explicitly checked the hashmap size to be >= CHAIN_CACHE_MAX first,
hence there must be something in the hashmap, hence the steal
operation cannot fail.

To make this clearer I have now added an assert() here.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list