libsepol: cil: prevent stack buffer overflow in cil_expr_to_string

Fix the test to prevent overflowing the stack buffer for
boolean expressions.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
This commit is contained in:
Stephen Smalley 2018-05-09 11:22:46 -04:00
parent 84b19ae72e
commit 3ca8762efd

View file

@ -339,7 +339,7 @@ static int cil_expr_to_string(struct cil_list *expr, char **out)
int pos = 0;
cil_list_for_each(curr, expr) {
if (pos > COND_EXPR_MAXDEPTH) {
if (pos >= COND_EXPR_MAXDEPTH) {
rc = SEPOL_ERR;
goto exit;
}