From 012dcb64897cc52bce18040a82ea483cf277858c Mon Sep 17 00:00:00 2001 From: John Johansen Date: Wed, 14 Aug 2024 09:06:12 -0700 Subject: [PATCH] parser: only use 32 bit next/check tables if required If the state machine does not requires more than 2^16 states use the dfa16 encoding for next/check tables to keep the dfa size small. Bug: https://gitlab.com/apparmor/apparmor/-/issues/419 Signed-off-by: John Johansen --- parser/libapparmor_re/chfa.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser/libapparmor_re/chfa.cc b/parser/libapparmor_re/chfa.cc index ffcc6f180..f6e103681 100644 --- a/parser/libapparmor_re/chfa.cc +++ b/parser/libapparmor_re/chfa.cc @@ -489,7 +489,8 @@ void flex_table_serialize(CHFA &chfa, ostream &os, void CHFA::flex_table(ostream &os, optflags const &opts) { - if (opts.control & CONTROL_DFA_STATE32) { + if (opts.control & CONTROL_DFA_STATE32 && + default_base.size() > (1 << 16) - 1) { // TODO: implement support for flags in separate table // if (opts.control & CONTROL_DFA_FLAGS_TABLE) { // if (opts.dump & DUMP_FLAGS_TABLE)