diff mbox series

[2/7,v2] libsepol/cil: Check the token type after getting the next token

Message ID 20210816195752.923028-3-jwcart2@gmail.com (mailing list archive)
State Accepted
Headers show
Series libsepol/cil: Line mark cleanup and fix | expand

Commit Message

James Carter Aug. 16, 2021, 7:57 p.m. UTC
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>
---
 libsepol/cil/src/cil_parser.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/libsepol/cil/src/cil_parser.c b/libsepol/cil/src/cil_parser.c
index fb95f401..fc90caec 100644
--- a/libsepol/cil/src/cil_parser.c
+++ b/libsepol/cil/src/cil_parser.c
@@ -111,6 +111,10 @@  static int add_hll_linemark(struct cil_tree_node **current, uint32_t *hll_lineno
 	unsigned long val;
 
 	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);
 	if (hll_type == CIL_KEY_HLL_LME) {
 		if (cil_stack_is_empty(stack)) {