libsepol/cil: Fix bug in cil_reset_ibpkeycon()

Nicolas Iooss <nicolas.iooss@m4x.org> discovered with clang's static
analyzer that cil_reset_ibpkeycon() was checking that ibpkeycon->context
was NULL and then passing the NULL value to cil_reset_context() which
expected a non-NULL argument.

Instead, cil_reset_ibpkeycon() should check if ibpkeycon->context_str
is NULL. If it is non-NULL then the context field points to a named
context that was created elsewhere and it will be reset there, but if
the context_str field is NULL, then the context is not named and needs
to be reset.

Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
This commit is contained in:
James Carter 2017-06-05 11:30:14 -04:00
parent 641d4ff55b
commit 738db6077b

View File

@ -290,7 +290,7 @@ static void cil_reset_filecon(struct cil_filecon *filecon)
static void cil_reset_ibpkeycon(struct cil_ibpkeycon *ibpkeycon)
{
if (!ibpkeycon->context)
if (!ibpkeycon->context_str)
cil_reset_context(ibpkeycon->context);
}