diff --git a/parser/libapparmor_re/chfa.cc b/parser/libapparmor_re/chfa.cc index 89e316de4..fcbc21485 100644 --- a/parser/libapparmor_re/chfa.cc +++ b/parser/libapparmor_re/chfa.cc @@ -92,10 +92,10 @@ CHFA::CHFA(DFA &dfa, map &eq, dfaflags_t flags): eq(eq) default_base.push_back(make_pair(dfa.nonmatching, 0)); num.insert(make_pair(dfa.nonmatching, num.size())); - accept.resize(dfa.states.size()); - accept2.resize(dfa.states.size()); - next_check.resize(optimal); - free_list.resize(optimal); + accept.resize(max(dfa.states.size(), 2ul)); + accept2.resize(max(dfa.states.size(), 2ul)); + next_check.resize(max(optimal, 256ul)); + free_list.resize(next_check.size()); accept[0] = 0; accept2[0] = 0; diff --git a/parser/parser_interface.c b/parser/parser_interface.c index fdd610df1..a8be7aa6b 100644 --- a/parser/parser_interface.c +++ b/parser/parser_interface.c @@ -361,7 +361,7 @@ inline int sd_write_blob(sd_serialize *p, void *b, int buf_size, char *name) return 1; } -#define align64(X) (((size_t) (X) + (size_t) 7) & ~((size_t) 7)) +#define align64(X) (((X) + (typeof(X)) 7) & ~((typeof(X)) 7)) inline int sd_write_aligned_blob(sd_serialize *p, void *b, int buf_size, char *name) { @@ -369,6 +369,7 @@ inline int sd_write_aligned_blob(sd_serialize *p, void *b, int buf_size, u32 tmp; if (!sd_write_name(p, name)) return 0; + pad = align64((p->pos + 5) - p->buffer) - ((p->pos + 5) - p->buffer); if (!sd_prepare_write(p, SD_BLOB, 4 + buf_size + pad)) return 0;