libsepol/cil: Check the token type after getting the next token

In add_hll_linemark(), cil_lexer_next() is called and the token
type is not checked after the call for the expected type (SYMBOL).

Check that the token type is SYMBOL after calling cil_lexer_next().

Signed-off-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
James Carter 2021-08-16 13:44:15 -04:00
parent 8823bea1b0
commit 2b988acf44

View File

@ -111,6 +111,10 @@ static int add_hll_linemark(struct cil_tree_node **current, uint32_t *hll_lineno
unsigned long val; unsigned long val;
cil_lexer_next(&tok); cil_lexer_next(&tok);
if (tok.type != SYMBOL) {
cil_log(CIL_ERR, "Invalid line mark syntax\n");
goto exit;
}
hll_type = cil_strpool_add(tok.value); hll_type = cil_strpool_add(tok.value);
if (hll_type == CIL_KEY_HLL_LME) { if (hll_type == CIL_KEY_HLL_LME) {
if (cil_stack_is_empty(stack)) { if (cil_stack_is_empty(stack)) {