libsepol/cil: call cil_reset_context() when context is not NULL
PATCH 1/1 libsepol/cil: call cil_reset_context() when context is not NULL
cil_reset_context() dereferences its argument, which is thus expected not to be NULL. The if statement in cil_reset_ibpkeycon() verified the opposite condition. Fix this.
This issue has been found using clang's static analyzer.
--- libsepol/cil/src/cil_reset_ast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_reset_ast.c +1 -1
@@ -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)cil_reset_context (ibpkeycon->context); }
Signature · 1 line
2.13.0
Quoted 7 lines · Nicolas Iooss
cil_reset_context()dereferences its argument, which is thus expected not to be NULL. The if statement incil_reset_ibpkeycon()verified the opposite condition. Fix this.This issue has been found using clang's static analyzer.
Signed-off-by Nicolas Iooss <[email protected]>
Thanks for the report.
Quoted 10 lines
--- libsepol/cil/src/cil_reset_ast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsepol/cil/src/cil_reset_ast.c +0
-0
libsepol/cil/src/cil_reset_ast.c static void cil_reset_filecon(struct cil_filecon *filecon) · line 296
Quoted 8 lines
libsepol/cil/src/cil_reset_ast.c +1
-1@@ -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)cil_reset_context (ibpkeycon->context); }
The real issue is that it should be checking ibpkeycon->context_str instead.
I have merged a fix crediting you with reporting the issue.
Jim
Signature · 2 lines
James Carter <[email protected]> National Security Agency