mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
Merge Revert "parser: fix potential padding bug." and fix code to for correct padding
This reverts commit 78ae95608753b42956f2445a4965b0577fbb76de. And the add the correct padding fix, so that the header size and what is written match. Signed-off-by: John Johansen <john.johansen@canonical.com> MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1274 Approved-by: Georgia Garcia <georgia.garcia@canonical.com> Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
b1a35e6cbd
@ -307,7 +307,7 @@ void *aare_rules::create_dfa(size_t *size, int *min_match_len, optflags const &o
|
||||
CHFA chfa(dfa, eq, opts);
|
||||
if (opts.dump & DUMP_DFA_TRANS_TABLE)
|
||||
chfa.dump(cerr);
|
||||
chfa.flex_table(stream, "");
|
||||
chfa.flex_table(stream);
|
||||
}
|
||||
catch(int error) {
|
||||
*size = 0;
|
||||
|
@ -368,7 +368,7 @@ template<class Iter>
|
||||
os << fill64(sizeof(td) + sizeof(*pos) * size);
|
||||
}
|
||||
|
||||
void CHFA::flex_table(ostream &os, const char *name)
|
||||
void CHFA::flex_table(ostream &os)
|
||||
{
|
||||
const char th_version[] = "notflex";
|
||||
struct table_set_header th = { 0, 0, 0, 0 };
|
||||
@ -419,7 +419,8 @@ void CHFA::flex_table(ostream &os, const char *name)
|
||||
|
||||
/* Write the actual flex parser table. */
|
||||
/* TODO: add max_oob */
|
||||
size_t hsize = pad64(sizeof(th) + sizeof(th_version) + 1 + strlen(name) + 1);
|
||||
// sizeof(th_version) includes trailing \0
|
||||
size_t hsize = pad64(sizeof(th) + sizeof(th_version));
|
||||
th.th_magic = htonl(YYTH_REGEX_MAGIC);
|
||||
th.th_flags = htons(chfaflags);
|
||||
th.th_hsize = htonl(hsize);
|
||||
@ -432,8 +433,8 @@ void CHFA::flex_table(ostream &os, const char *name)
|
||||
flex_table_size(next_vec.begin(), next_vec.end()) +
|
||||
flex_table_size(check_vec.begin(), check_vec.end()));
|
||||
os.write((char *)&th, sizeof(th));
|
||||
os << th_version << (char)0 << name << (char)0;
|
||||
os << fill64(sizeof(th) + 1 + sizeof(th_version) + strlen(name) + 1);
|
||||
os.write(th_version, sizeof(th_version));
|
||||
os << fill64(sizeof(th) + sizeof(th_version));
|
||||
|
||||
write_flex_table(os, YYTD_ID_ACCEPT, accept.begin(), accept.end());
|
||||
write_flex_table(os, YYTD_ID_ACCEPT2, accept2.begin(), accept2.end());
|
||||
|
@ -39,7 +39,7 @@ class CHFA {
|
||||
public:
|
||||
CHFA(DFA &dfa, map<transchar, transchar> &eq, optflags const &opts);
|
||||
void dump(ostream & os);
|
||||
void flex_table(ostream &os, const char *name);
|
||||
void flex_table(ostream &os);
|
||||
void init_free_list(vector<pair<size_t, size_t> > &free_list,
|
||||
size_t prev, size_t start);
|
||||
bool fits_in(vector<pair<size_t, size_t> > &free_list, size_t base,
|
||||
|
Loading…
x
Reference in New Issue
Block a user