libsepol: bool_copy_callback set state on creation

Boolean states are only written on a declaration.
If a module is turned off which includes a tunable declaration that
is required in another module, the state is never set. This patch
sets the state when the booldatum is created so that an uninitialized
memory read does not occur in cond_write_bool and write garbage to
the link binary.  This can cause a failure in cond_read_bool when
running semodule_expand.

Signed-off-by: Thomas Hurd <thurd@tresys.com>
This commit is contained in:
Thomas Hurd 2015-03-19 13:03:49 -04:00 committed by Stephen Smalley
parent 072bb765a1
commit c046d974c5
1 changed files with 1 additions and 0 deletions

View File

@ -630,6 +630,7 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum,
state->base->p_bools.nprim++;
base_bool = new_bool;
base_bool->flags = booldatum->flags;
base_bool->state = booldatum->state;
} else if ((booldatum->flags & COND_BOOL_FLAGS_TUNABLE) !=
(base_bool->flags & COND_BOOL_FLAGS_TUNABLE)) {
/* A mismatch between boolean/tunable declaration